Skip to content

Commit

Permalink
refactor: improve InvalidViewParameterError message format
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed May 10, 2023
1 parent c1987f3 commit f78a1bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/taquito-core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ export class InvalidViewParameterError extends ParameterValidationError {
constructor(public viewName: string, public sigs: any, public args: any, public cause?: any) {
super();
this.name = 'InvalidViewParameterError';
this.message = `view name: ${viewName} received arguments: ${JSON.stringify(
this.message = `Invalid arguments ${JSON.stringify(
args
)} while expecting one of the following signatures: (${JSON.stringify(sigs)}).`;
)} received for view name "${viewName}", expecting one of the following signatures: "${JSON.stringify(
sigs
)}".`;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/taquito-core/test/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ describe('common error classes', () => {
expect(error).toBeInstanceOf(ParameterValidationError);
expect(error).toBeInstanceOf(InvalidViewParameterError);
expect(error.message).toEqual(
`view name: foo received arguments: "bar" while expecting one of the following signatures: (${JSON.stringify(
`Invalid arguments "bar" received for view name "foo", expecting one of the following signatures: "${JSON.stringify(
{ parameter: 'nat', result: 'nat' }
)}).`
)}".`
);
}
});
Expand Down

0 comments on commit f78a1bd

Please sign in to comment.