Skip to content

Instantly share code, notes, and snippets.

@dpeek
Last active May 30, 2017 20:49
Show Gist options
  • Select an option

  • Save dpeek/a9bb8231c4c64451cef119f67d21bdb1 to your computer and use it in GitHub Desktop.

Select an option

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