From 60dd0553713e575bf44ba12bc5cc9892002e6932 Mon Sep 17 00:00:00 2001 From: Robert Knight <95928279+microbit-robert@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:57:38 +0000 Subject: [PATCH] Improve serial error logging (#42) --- lib/device.ts | 2 +- lib/usb-radio-bridge.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/device.ts b/lib/device.ts index e42502a..6509a77 100644 --- a/lib/device.ts +++ b/lib/device.ts @@ -179,7 +179,7 @@ export class DeviceConnectionEventMap { "status": ConnectionStatusEvent; "serialdata": SerialDataEvent; "serialreset": Event; - "serialerror": Event; + "serialerror": SerialErrorEvent; "flash": Event; "beforerequestdevice": Event; "afterrequestdevice": Event; diff --git a/lib/usb-radio-bridge.ts b/lib/usb-radio-bridge.ts index 6ed83eb..cf8569d 100644 --- a/lib/usb-radio-bridge.ts +++ b/lib/usb-radio-bridge.ts @@ -13,6 +13,7 @@ import { DeviceConnection, DeviceConnectionEventMap, SerialDataEvent, + SerialErrorEvent, } from "./device.js"; import { TypedEventTarget } from "./events.js"; import { Logging, NullLogging } from "./logging.js"; @@ -223,8 +224,8 @@ class RadioBridgeSerialSession { private connectionCheckIntervalId: ReturnType | undefined; private isRestartingConnection: boolean = false; - private serialErrorListener = (e: unknown) => { - this.logging.error("Serial error", e); + private serialErrorListener = (event: SerialErrorEvent) => { + this.logging.error("SerialError:", event.error); void this.dispose(); };