Allow Node command handlers to throw responses and non-Error objects
This commit is contained in:
parent
bb9cdbd15e
commit
bccd0ed4e0
@ -1305,15 +1305,22 @@ export default class PeerClient {
|
|||||||
success: false,
|
success: false,
|
||||||
status: err.response.status,
|
status: err.response.status,
|
||||||
}
|
}
|
||||||
|
} else if ("status" in err) {
|
||||||
|
resp.response = err
|
||||||
} else {
|
} else {
|
||||||
resp.command = "error"
|
resp.command = "error"
|
||||||
|
let errorDetails
|
||||||
if (err instanceof ProtocolError) {
|
if (err instanceof ProtocolError) {
|
||||||
resp.error = err.message
|
resp.error = err.message
|
||||||
this.error(`Response ${resp.id}: ${err.message}`)
|
errorDetails = err.message
|
||||||
} else {
|
} else if (err instanceof Error) {
|
||||||
resp.error = err.toString()
|
resp.error = err.toString()
|
||||||
this.error(`Response ${resp.id}: ${err.stack}`)
|
errorDetails = err.stack
|
||||||
|
} else {
|
||||||
|
resp.error = JSON.stringify(err)
|
||||||
|
errorDetails = `throwed ${resp.error}`
|
||||||
}
|
}
|
||||||
|
this.error(`Response ${resp.id}: ${errorDetails}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resp.response) {
|
if (resp.response) {
|
||||||
|
Loading…
Reference in New Issue
Block a user