Closed nodesocket closed 8 years ago
I use instanceof
to check against error types, which has been working well.
const thinky = new Thinky(/* settings */);
try {
const document = yield Model.save();
} catch (err) {
if (err instanceof thinky.Errors.DocumentNotFound) {
// handle error
}
}
Ahh perfect, thanks.
if(error instanceof thinky.Errors.ValidationError) {
...
}
you can also use filtered Promise.catch
statements
query
.then(handleSuccess)
.catch(Errors.DocumentNotFound, handleDoesntExist)
.catch( err => /*unexpected error, like network partition */ )
Is there a better way to check the error type that comes back on a
save()
? Currently I am doing: