hyperledger-cacti / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
344 stars 286 forks source link

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

Closed petermetz closed 4 weeks ago

petermetz commented 1 month ago

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

Character Limit

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