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

Static Errors class to throw and document all errors in the library #469

Open
2 tasks done
HoyosJuan opened this issue Aug 12, 2024 · 0 comments
Open
2 tasks done
Labels
feature Something new that we could do

Comments

@HoyosJuan
Copy link
Member

Description 📝

Would be great to throw all library errors from the same class in order to have a single place to create documentation for them. Also, this is beneficial in cases where many components throw the same errors.

Suggested solution 💡

Create a core Errors class with static properties to throw a document errors:

class Errors {
  /**
   * Indications on what the error means and how the developer can solve it.
   */
  noWorld = new Error("No world found!")
}

From any component:

import { Errors } from "core"

class Component {
  someMethod() {
    if (somethingFails) {
      throw new Errors.noWorld
    }
  }
}

Alternative ⛕

No response

Additional context ☝️

No response

Validations ✅

  • Read the docs.
  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
@HoyosJuan HoyosJuan added the feature Something new that we could do label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new that we could do
Projects
None yet
Development

No branches or pull requests

1 participant