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

build: migrate to Typescript target of ES2022 and use Error.cause #3592

Closed
petermetz opened this issue Oct 17, 2024 · 0 comments · Fixed by #3593
Closed

build: migrate to Typescript target of ES2022 and use Error.cause #3592

petermetz opened this issue Oct 17, 2024 · 0 comments · Fixed by #3593
Assignees
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Milestone

Comments

@petermetz
Copy link
Contributor

Description

The Error.cause proposal has reached stage 4 and implementation is widespread enough that we can count on all major browsers and all LTS supported NodeJS versions to work with it as well.

This is revolutionary when it comes to error handling in Javascript/Typescript because up until now you had to have a convention enforced (painstakingly via code reviews) for making sure that junior talent does not lose the cause of exceptions thrown in the code.

While this is still a possibility, it was made much harder with the new Error.cause API

https://github.com/tc39/proposal-error-cause

image

Acceptance Criteria

  1. The build configuration has been upgraded so that the compiler uses a target of ES2022
  2. Tests are still passing
  3. No issues with the cmd-api-server bundling either.
@petermetz petermetz added enhancement New feature or request javascript Pull requests that update Javascript code labels Oct 17, 2024
@petermetz petermetz added this to the v2.1.0 milestone Oct 17, 2024
@petermetz petermetz self-assigned this Oct 17, 2024
petermetz added a commit to petermetz/cacti that referenced this issue Oct 17, 2024
Project-wide upgrade to Typescript target of ES2022 so that we can use
the new Error APIs.

Wherever possible we should now use the new `cause`
property of the built-in `Error` type in combination
with the `asError(unknown)` utility function:
```typescript
import { asError } from "@hyperledger/cactus-common";

try {
    await performSomeImportantOperation();
} catch (ex: unknown) {
    const cause = asError(ex);
    throw new Error("Something went wrong while doing something.", { cause });
}
```
More information about the EcmaScript proposal that made this possible:
https://github.com/tc39/proposal-error-cause

Fixes hyperledger-cacti#3592

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Oct 24, 2024
Project-wide upgrade to Typescript target of ES2022 so that we can use
the new Error APIs.

Wherever possible we should now use the new `cause`
property of the built-in `Error` type in combination
with the `asError(unknown)` utility function:
```typescript
import { asError } from "@hyperledger/cactus-common";

try {
    await performSomeImportantOperation();
} catch (ex: unknown) {
    const cause = asError(ex);
    throw new Error("Something went wrong while doing something.", { cause });
}
```
More information about the EcmaScript proposal that made this possible:
https://github.com/tc39/proposal-error-cause

Fixes hyperledger-cacti#3592

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant