Skip to content

How to pass variables into the error message. #66

@santanuyogi

Description

@santanuyogi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions