Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Jun 24, 2024
1 parent 020e66c commit 3982f06
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Enum extends XdrPrimitiveType {
static write(value, writer) {
if (!isValid(value)) {
throw new XdrWriterError(
`${value} is ${value?.constructor?.name}, not ${
`${value} is ${value?.constructor?.name}/${value?.enumName}, not ${
this.enumName
}: ${JSON.stringify(value)}`
);
Expand Down
2 changes: 1 addition & 1 deletion src/struct.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Struct extends XdrPrimitiveType {
static write(value, writer) {
if (!this.isValid(value)) {
throw new XdrWriterError(
`${value} is ${value?.constructor?.name}, not ${
`${value} is ${value?.constructor?.name}/${value?.structName}, not ${
this.structName
}: ${JSON.stringify(value)}`
);
Expand Down
6 changes: 3 additions & 3 deletions src/union.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export class Union extends XdrCompositeType {
static write(value, writer) {
if (!this.isValid(value)) {
throw new XdrWriterError(
`${value} is ${value?.constructor?.name}/${
value?.constructor?.unionName
}, not ${this.unionName}: ${JSON.stringify(value)}`
`${value} is ${value?.constructor?.name}/${value?.unionName}, not ${
this.unionName
}: ${JSON.stringify(value)}`
);
}

Expand Down

0 comments on commit 3982f06

Please sign in to comment.