Skip to content

Commit adff148

Browse files
committed
fix: export BluetoothError and improve BluetoothError logging
1 parent 6a66786 commit adff148

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/ble/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function getBluetoothInstance() {
3838
return _bluetoothInstance;
3939
}
4040

41-
export { BleTraceCategory };
41+
export { BleTraceCategory, BluetoothError };
4242

4343
const sdkVersion = parseInt(Device.sdkVersion, 10);
4444
let context: android.content.Context;

src/ble/index.common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ export class BluetoothError extends BaseError {
1919
arguments?: any; // call argumrents
2020
method?: string; // call argumrents
2121
status?: number; // call argumrents
22+
nativeException?: any;
2223
constructor(message: string, properties?: { [k: string]: any }) {
2324
super(message);
2425
if (properties) {
2526
Object.assign(this, properties);
2627
}
2728
}
2829
toString() {
29-
return `[BluetoothError]:${this.message}, ${this.method}, ${this.status}, ${JSON.stringify(this.arguments)}`;
30+
return `[BluetoothError]:${this.message} in:${this.method}${this.status ? ` with status:${this.status}` : ''}${
31+
this.nativeException ? ` with nativeException:${this.nativeException}` : ''
32+
} args: ${JSON.stringify(this.arguments)}`;
3033
}
3134
}
3235

src/ble/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
AdvertismentData,
33
BleTraceCategory,
44
BluetoothCommon,
5+
BluetoothError,
56
BluetoothOptions,
67
CallbackType,
78
Characteristic,
@@ -27,6 +28,7 @@ import {
2728

2829
export {
2930
AdvertismentData,
31+
BluetoothError,
3032
BleTraceCategory,
3133
CallbackType,
3234
Characteristic,

src/ble/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from './index.common';
2525
import { Trace } from '@nativescript/core';
2626

27-
export { BleTraceCategory };
27+
export { BleTraceCategory, BluetoothError };
2828

2929
function nativeEncoding(encoding: string) {
3030
switch (encoding) {

0 commit comments

Comments
 (0)