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

TypeScript Does Not See error.original in Error Handler #925

Closed
5 of 10 tasks
raycharius opened this issue May 18, 2021 · 1 comment · Fixed by #927
Closed
5 of 10 tasks

TypeScript Does Not See error.original in Error Handler #925

raycharius opened this issue May 18, 2021 · 1 comment · Fixed by #927
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor TypeScript-specific
Milestone

Comments

@raycharius
Copy link
Contributor

raycharius commented May 18, 2021

Description

The error that comes through to the global error handler is typed as CodedError, and as such, when trying to reference the original or originals property, TypeScript says that it does not exist.

So far, this is the only thing that has worked:

app.error(async (error) => {
    if (error instanceof UnknownError) {
      // Do something with error.original
    }
  });

While this works, it is very restrictive. If a new type of error were to be introduced into Bolt with an original property, it would not make its way into this block of code.

A much more preferred way would be something like:

if (Boolean(error.original)) {
  // Do something with error.original
}

Or even:

if (error.hasOwnProperty('original')) {
  // Do something with error.original
}

Perhaps it would make sense to add all possible optional properties to the CodedError interface?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

@gitwave gitwave bot added the untriaged label May 18, 2021
@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor TypeScript-specific and removed untriaged labels May 18, 2021
@seratch seratch added this to the 3.4.0 milestone May 18, 2021
@seratch
Copy link
Member

seratch commented May 18, 2021

@raycharius Thanks a lot for reporting this! We'll look into this and will have a fix in the next minor verison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:minor TypeScript-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants