Skip to content

Commit

Permalink
Error handling for mandatory struct definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiRegiani committed Nov 25, 2024
1 parent c3f4985 commit 8566e70
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ class Struct extends ResolvedType {
this.flagsPosition = description.flagsPosition
}

if (!description.name) {
throw new Error(`Struct ${this.fqn}: required 'name' definition is missing`)
}

if (!description.fields) {
throw new Error(`Struct ${this.fqn}: required 'fields' definition is missing`)
}

if (this.existing) {
const oldLength = this.existing.fields.length
const newLength = this.description.fields.length
Expand Down

0 comments on commit 8566e70

Please sign in to comment.