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 #3593

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

petermetz
Copy link
Contributor

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:

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 #3592

Signed-off-by: Peter Somogyvari peter.somogyvari@accenture.com

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

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 petermetz force-pushed the petermetz/issue3592 branch from c5dc99e to 1e90622 Compare October 24, 2024 20:01
@petermetz petermetz merged commit ff842d2 into hyperledger-cacti:main Oct 24, 2024
143 of 146 checks passed
@petermetz petermetz deleted the petermetz/issue3592 branch October 24, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build: migrate to Typescript target of ES2022 and use Error.cause
3 participants