Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export errors codes to allow translation #13

Closed
nkint opened this issue Oct 10, 2019 · 1 comment
Closed

Export errors codes to allow translation #13

nkint opened this issue Oct 10, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@nkint
Copy link

@nkint nkint commented Oct 10, 2019

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Free support
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v12.11.1
  • module version: latest
  • environment (e.g. node, browser, native): browser
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information: Typescript 3.6.2

What problem are you trying to solve?

Hi, thanks for the template and the code of conduct - very inspirational words. Hope everything will be ok with this issue.

I'd like to use this address module: it is very exhaustive and I love the detailed feedback it gives back in case of error.

But I also need to translate error codes so I would like to have a list of all errors used and / or error codes. In my case have a translation/error-codes is mandatory and can compromise to use or not this library.

Do you have a new or modified API suggestion to solve the problem?

I'm here to discuss what is the best way to do it (if this can be a good idea for the maintainer) and hopefully find the time to have a mini pull-request.

One idea can be:

const errorsByCode = {
    BE_STRING: 'Invalid input: email must be a string',
	BE_NON_EMPTY_STRING: 'Address must be a non-empty string',
    // ....
};

module.exports = {
	errorsByCode,
    domain: {
        // ....
    },
    email: {
        // ....       
    }
};

// use the error-codes in the rest of the source code

What do you think?

@nkint nkint added the feature label Oct 10, 2019
@hueniverse hueniverse self-assigned this Oct 10, 2019
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Oct 10, 2019

I'm open to it. The above looks like a good start. Feel free to submit a PR.

hueniverse added a commit that referenced this issue Oct 16, 2019
Error codes in a separate file. Closes #13
@hueniverse hueniverse added this to the 3.0.1 milestone Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.