Skip to content

Commit

Permalink
Merge pull request #143 from streamflow-finance/feat/add-meaningful-e…
Browse files Browse the repository at this point in the history
…rror-description

feat: add meaningful error msg to all distributor errors
  • Loading branch information
RolginRoman authored Mar 13, 2024
2 parents 4f5eed3 + dd8d098 commit 25ad920
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/common",
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"description": "Common utilities and types used by streamflow packages.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ export enum IChain {
export class ContractError extends Error {
public contractErrorCode: string | null;

public description: string | null;

/**
* Constructs the Error Wrapper
* @param error Original error raised probably by the chain SDK
* @param code extracted code from the error if managed to parse it
*/
constructor(error: Error, code?: string | null) {
constructor(error: Error, code?: string | null, description?: string | null) {
super(error.message); // Call the base class constructor with the error message
this.contractErrorCode = code ?? null;
this.description = description ?? null;
// Copy properties from the original error
Object.setPrototypeOf(this, ContractError.prototype);
this.name = "ContractError"; // Set the name property
Expand Down
2 changes: 1 addition & 1 deletion packages/distributor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/distributor",
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/distributor/solana/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function wrappedSignAndExecuteTransaction(
if (err instanceof Error) {
const parsed = fromTxError(err);
if (parsed) {
throw new ContractError(err, parsed.name);
throw new ContractError(err, parsed.name, parsed.msg);
}
}
throw err;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/eslint-config",
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"license": "ISC",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "6.0.0-alpha.3",
"version": "6.0.0-alpha.4",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down

0 comments on commit 25ad920

Please sign in to comment.