feat: error handling
This commit is contained in:
parent
7e4e3e12ee
commit
a424101ee3
|
@ -9,7 +9,20 @@ export class Packet {
|
|||
|
||||
static get builder() {
|
||||
if (!this._builder) {
|
||||
this._builder = schemapack.build(this.schema);
|
||||
const schema = this.schema;
|
||||
if (!schema._id) {
|
||||
throw new Error([
|
||||
`No packet id found in '${this.name}.schema'. This is usually due to forgetting to`,
|
||||
'inherit from Packet.schema within your packet subclass schema definition.',
|
||||
].join(' '));
|
||||
}
|
||||
if (!schema.data) {
|
||||
throw new Error([
|
||||
`No data found in '${this.name}.schema'. This is usually due to forgetting to`,
|
||||
'inherit from Packet.schema within your packet subclass schema definition.',
|
||||
].join(' '));
|
||||
}
|
||||
this._builder = schemapack.build(schema);
|
||||
}
|
||||
return this._builder;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user