Initial commit of akmon project
This commit is contained in:
34
uni_modules/ak-sbsrv/utssdk/unierror.uts
Normal file
34
uni_modules/ak-sbsrv/utssdk/unierror.uts
Normal file
@@ -0,0 +1,34 @@
|
||||
// Minimal error definitions used across the BLE module.
|
||||
// Keep this file small and avoid runtime dependencies; it's mainly for typing and
|
||||
// simple runtime error construction used by native platform code.
|
||||
|
||||
export enum AkBluetoothErrorCode {
|
||||
UnknownError = 0,
|
||||
DeviceNotFound = 1,
|
||||
ServiceNotFound = 2,
|
||||
CharacteristicNotFound = 3,
|
||||
ConnectionTimeout = 4,
|
||||
Unspecified = 99
|
||||
}
|
||||
|
||||
export class AkBleErrorImpl extends Error {
|
||||
public code: AkBluetoothErrorCode;
|
||||
public detail: any|null;
|
||||
constructor(code: AkBluetoothErrorCode, message?: string, detail: any|null = null) {
|
||||
super(message ?? AkBleErrorImpl.defaultMessage(code));
|
||||
this.name = 'AkBleError';
|
||||
this.code = code;
|
||||
this.detail = detail;
|
||||
}
|
||||
static defaultMessage(code: AkBluetoothErrorCode) {
|
||||
switch (code) {
|
||||
case AkBluetoothErrorCode.DeviceNotFound: return 'Device not found';
|
||||
case AkBluetoothErrorCode.ServiceNotFound: return 'Service not found';
|
||||
case AkBluetoothErrorCode.CharacteristicNotFound: return 'Characteristic not found';
|
||||
case AkBluetoothErrorCode.ConnectionTimeout: return 'Connection timed out';
|
||||
case AkBluetoothErrorCode.UnknownError: default: return 'Unknown Bluetooth error';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AkBleErrorImpl;
|
||||
Reference in New Issue
Block a user