diff options
author | José Luis Millán <jmillan@aliax.net> | 2023-04-26 07:22:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 22:22:06 -0700 |
commit | aa6848fbf652600593370bf6ab24e61b2092bead (patch) | |
tree | b809334c63103e98d2525e6cf39e2f85eb356c24 | |
parent | 6c8a8d054d27b5149d2daf90609a47214e55d633 (diff) | |
download | flatbuffers-aa6848fbf652600593370bf6ab24e61b2092bead.tar.gz flatbuffers-aa6848fbf652600593370bf6ab24e61b2092bead.tar.bz2 flatbuffers-aa6848fbf652600593370bf6ab24e61b2092bead.zip |
TS/JS: Use TypeError instead of Error when appropriate (#7910)
Ie: when the needed conditions are not satisfied in order to perform a
given action.
-rw-r--r-- | ts/builder.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ts/builder.ts b/ts/builder.ts index 4ba34035..fe496ab0 100644 --- a/ts/builder.ts +++ b/ts/builder.ts @@ -268,7 +268,7 @@ export class Builder { */ nested(obj: Offset): void { if (obj != this.offset()) { - throw new Error('FlatBuffers: struct must be serialized inline.'); + throw new TypeError('FlatBuffers: struct must be serialized inline.'); } } @@ -278,7 +278,7 @@ export class Builder { */ notNested(): void { if (this.isNested) { - throw new Error('FlatBuffers: object serialization must not be nested.'); + throw new TypeError('FlatBuffers: object serialization must not be nested.'); } } @@ -429,7 +429,7 @@ export class Builder { this.prep(this.minalign, SIZEOF_INT + FILE_IDENTIFIER_LENGTH + size_prefix); if (file_identifier.length != FILE_IDENTIFIER_LENGTH) { - throw new Error('FlatBuffers: file identifier must be length ' + + throw new TypeError('FlatBuffers: file identifier must be length ' + FILE_IDENTIFIER_LENGTH); } for (let i = FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) { @@ -463,7 +463,7 @@ export class Builder { // If this fails, the caller will show what field needs to be set. if (!ok) { - throw new Error('FlatBuffers: field ' + field + ' must be set'); + throw new TypeError('FlatBuffers: field ' + field + ' must be set'); } } @@ -576,7 +576,7 @@ export class Builder { if(val !== null) { ret.push(this.createObjectOffset(val)); } else { - throw new Error( + throw new TypeError( 'FlatBuffers: Argument for createObjectOffsetList cannot contain null.'); } } |