Last active
May 30, 2017 20:49
-
-
Save dpeek/a9bb8231c4c64451cef119f67d21bdb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type ErrorResponse = { | |
code: 'Error', | |
message: string | |
} | |
type ResultResponse = {} | |
function test (): Promise<ResultResponse | ErrorResponse> { | |
return new Promise(() => {}) | |
} | |
test().then(res => { | |
if (res.code === 'Error') { | |
throw new Error(res.message) | |
} | |
return res | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment