Throw consistent error messages.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user