Throw consistent error messages.

This commit is contained in:
László Monda
2016-03-29 00:34:49 +02:00
parent 0aeec88cb5
commit b2f5bf1d66
2 changed files with 13 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
set scancode(value) {
if (!KeystrokeAction.isScancodeValid(value)) {
throw 'Scancode ${scancode} is invalid!';
throw 'Invalid KeystrokeAction.scancode: ${scancode}';
}
this._scancode = value;
}
@@ -32,6 +32,12 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
return this;
}
fromBinary(buffer: UhkBuffer): KeystrokeAction {
this.scancode = buffer.readUInt8();
this.modifierMask = buffer.readUInt8();
return this;
}
toJsObject(): any {
return {
keyActionType: KeystrokeAction.actionTypeString,
@@ -40,12 +46,6 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
};
}
fromBinary(buffer: UhkBuffer): KeystrokeAction {
this.scancode = buffer.readUInt8();
this.modifierMask = buffer.readUInt8();
return this;
}
toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(this.scancode);
buffer.writeUInt8(this.modifierMask);