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

Create Exception class #259

Open
3 of 6 tasks
Tracked by #238
nexushoratio opened this issue Feb 23, 2024 · 0 comments
Open
3 of 6 tasks
Tracked by #238

Create Exception class #259

nexushoratio opened this issue Feb 23, 2024 · 0 comments
Assignees
Labels
cleanup This doesn't seem right, refactor, etc library For libraries linkedin-tool For the LinkedIn Tool userscript

Comments

@nexushoratio
Copy link
Owner

nexushoratio commented Feb 23, 2024

Inheriting from Error does NOT update the name property, so new exceptions will show the wrong name. Overriding to use this.constructor.name is common.

Currently, all of our custom ones override the constructor, but providing a get name() works as well. We should do that, and update all modules to use it for module level exceptions.

The xunit library has a special case inside TestCase that could be move away from the ctor to a getter as well.

  • Implement and export
  • Update main modules to use newer version of base.
  • Update various modules to use this instead of each having their own custom
  • Update xunit's special case
  • Update main modules to use newest versions of all libraries and new class name
  • Retire old class name from various libraries

Starting state:

$ grep extends.Error **/*.js
lib/userscript.js:  class UserscriptError extends Error {
lib/widget.js:  class WidgetError extends Error {
lib/xunit.js:    static Error = class extends Error {
linkedin-tool.user.js:    static Error = class extends Error {
@nexushoratio nexushoratio added cleanup This doesn't seem right, refactor, etc linkedin-tool For the LinkedIn Tool userscript library For libraries labels Feb 23, 2024
@nexushoratio nexushoratio self-assigned this Feb 23, 2024
@nexushoratio nexushoratio changed the title Create BaseError class Create Exception class Feb 24, 2024
nexushoratio pushed a commit that referenced this issue Feb 25, 2024
When exception types inherit from `Error`, the *name* property sticks with the
string "Error", making logs less useful.

Issue #259.

␄
nexushoratio pushed a commit that referenced this issue Feb 26, 2024
This is to grab the new `Exception` class.

Issue #259.

␄
nexushoratio pushed a commit that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup This doesn't seem right, refactor, etc library For libraries linkedin-tool For the LinkedIn Tool userscript
Projects
None yet
Development

No branches or pull requests

1 participant