Skip to content

Instantly share code, notes, and snippets.

@dpeek
Last active May 30, 2017 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpeek/a9bb8231c4c64451cef119f67d21bdb1 to your computer and use it in GitHub Desktop.
Save dpeek/a9bb8231c4c64451cef119f67d21bdb1 to your computer and use it in GitHub Desktop.
/* @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