Skip to content

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

Closed
@HoyosJuan

Description

@HoyosJuan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureSomething new that we could do

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions