I'm trying to create a filter hook that needs to check a user's balance before allowing a mutation to happen. I'm using something like the following:
const testError = createError('test', 'test', 400);
if(!user.balance) {
throw new testError();
}
The directus console logs show this:
[13:55:05.089] ERROR: test
err: {
"type": "GraphQLError",
"message": "test",
"stack":
DirectusError: test
...
"path": [
"create_picks_item"
],
"locations": [
{
"line": 2,
"column": 3
}
],
"extensions": {
"code": "TEST"
}
}
Which looks like the error is being hit properly. But the front API call just shows this in the network response:
{
"data": {
"create_picks_item": null
},
"errors": [
{
"message": "An unexpected error occurred.",
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
}
Is there a way that I can have my custom test error sent in the response instead of the generic INTERNAL_SERVER_ERROR that it's giving now?