diff --git a/packages/net/packet/packet.js b/packages/net/packet/packet.js index 4134b65..65a8cce 100644 --- a/packages/net/packet/packet.js +++ b/packages/net/packet/packet.js @@ -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; }