apollo-errors
apollo-errors copied to clipboard
How to pass variables into the error message.
This is more of a question than it is an issue. Is there any way to pass a variable into the error message?
If I have the following error message:
throw new Error(
`There was no user found with the username, ${username}.`
);
How can I get that username into the apollo-errors? Is there a way to pass it as an argument?
throw new err.IncorrectUsernameError(username);
Inside my error file that imports apollo-errors:
exports.IncorrectUsernameError = createError('IncorrectPasswordError', {
message: `There was no user found with the username, ${username}.`,
});
Please let me know if there is some way to accomplish this.
Hi, just found this library, but I think you could achieve that behavior using a HOC to wrap the error creation, that way you could send a custom message, maybe it's too late for the reply but someone might find it useful
Also, you could just overload the message as it's in the docs