-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Hello guys,
I've following custom error class
class TypedError extends Error {
constructor(message: string, public code: number) {
super(message)
// Set the prototype explicitly.
Object.setPrototypeOf(this, TypedError.prototype)
}
}which I use in controller like
@Mutation()
raiseAnError() {
throw new TypedError('Not found', 404)
}however, using the playground I only get following with no Error.code
"errors": [
{
"message": "Not found",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"raiseAnError"
]
}
]How can I achieve something like (https://codeburst.io/custom-errors-and-error-reporting-in-graphql-bbd398272aeb)
formatError(err) {
errors.report(err, req); // <-- log the error
return {
message: err.message,
code: err.originalError && err.originalError.code, // <--
locations: err.locations,
path: err.path
};
}```Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels