From 4b90a1a8da7436552bffeddf3c2d12500eeddd07 Mon Sep 17 00:00:00 2001 From: lights0123 Date: Tue, 6 Apr 2021 17:26:08 -0400 Subject: [PATCH] Error messages during passive operation --- n-link-core/components/devices.ts | 1 + web/.eslintrc.js | 4 ++++ web/components/devices.ts | 2 ++ web/pages/index.vue | 5 ++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/n-link-core/components/devices.ts b/n-link-core/components/devices.ts index 9de2271..2bfe6d9 100644 --- a/n-link-core/components/devices.ts +++ b/n-link-core/components/devices.ts @@ -41,6 +41,7 @@ export interface GenericDevices { devices: Record; enumerating: boolean; hasEnumerated: boolean; + errorHandler?: (e: DOMException) => void; enumerate(): Promise; open(dev: string): Promise; diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 561a41d..e72602f 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -18,5 +18,9 @@ module.exports = { 'import/no-webpack-loader-syntax': 0, 'require-await': 0, 'unicorn/number-literal-case': 0, + 'no-console': + process.env.NODE_ENV === 'production' + ? ['warn', { allow: ['warn', 'error'] }] + : 'off', }, }; diff --git a/web/components/devices.ts b/web/components/devices.ts index 0f38c16..86945e2 100644 --- a/web/components/devices.ts +++ b/web/components/devices.ts @@ -93,6 +93,7 @@ class Devices extends Vue implements GenericDevices { enumerating = false; hasEnumerated = false; devices: Record = {}; + errorHandler?: (e: DOMException) => void; created() {} @@ -137,6 +138,7 @@ class Devices extends Vue implements GenericDevices { } } catch (e) { console.error(e); + this.errorHandler?.(e); } if ('progress' in device) this.$delete(device, 'progress'); device.queue.shift(); diff --git a/web/pages/index.vue b/web/pages/index.vue index 2966507..a552e07 100644 --- a/web/pages/index.vue +++ b/web/pages/index.vue @@ -93,7 +93,7 @@