Skip to content

Commit

Permalink
Merge pull request #62 from airswap/response-handling
Browse files Browse the repository at this point in the history
More explicit response handling for peer calls
  • Loading branch information
Don Mosites committed Feb 14, 2020
2 parents 80d250e + e331733 commit be84776
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/commands/quote/get.ts
Expand Up @@ -32,8 +32,10 @@ export default class QuoteGet extends Command {
this.log()
}
process.exit(0)
} else {
} else if (quote) {
await printOrder(this, request, locator, quote, wallet, metadata)
} else {
this.log('No valid response received.\n')
}
})
} catch (e) {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/requests.ts
Expand Up @@ -48,13 +48,13 @@ export function peerCall(locator: string, method: string, params: any, callback:

client.request(method, params, function(err: any, error: any, result: any) {
if (err) {
callback(`\n${chalk.yellow('Connection Error')}: ${locator} \n ${err}`)
callback(`\n${chalk.yellow('Server Error')}: ${locator} \n ${err}`, null)
} else if (error) {
callback(`\n${chalk.yellow('Maker Error')}: ${error.message}\n`, null)
} else if (result) {
callback(null, result)
} else {
if (error) {
callback(`\n${chalk.yellow('Error Response')}: ${error.message}\n`)
} else {
callback(null, result)
}
callback(null, null)
}
})
}
Expand Down

0 comments on commit be84776

Please sign in to comment.