Error messages during passive operation

This commit is contained in:
lights0123 2021-04-06 17:26:08 -04:00
parent ac1a26a797
commit 4b90a1a8da
No known key found for this signature in database
GPG key ID: 28F315322E37972F
4 changed files with 11 additions and 1 deletions

View file

@ -41,6 +41,7 @@ export interface GenericDevices {
devices: Record<string, Device>; devices: Record<string, Device>;
enumerating: boolean; enumerating: boolean;
hasEnumerated: boolean; hasEnumerated: boolean;
errorHandler?: (e: DOMException) => void;
enumerate(): Promise<void>; enumerate(): Promise<void>;
open(dev: string): Promise<void>; open(dev: string): Promise<void>;

View file

@ -18,5 +18,9 @@ module.exports = {
'import/no-webpack-loader-syntax': 0, 'import/no-webpack-loader-syntax': 0,
'require-await': 0, 'require-await': 0,
'unicorn/number-literal-case': 0, 'unicorn/number-literal-case': 0,
'no-console':
process.env.NODE_ENV === 'production'
? ['warn', { allow: ['warn', 'error'] }]
: 'off',
}, },
}; };

View file

@ -93,6 +93,7 @@ class Devices extends Vue implements GenericDevices {
enumerating = false; enumerating = false;
hasEnumerated = false; hasEnumerated = false;
devices: Record<string, Device> = {}; devices: Record<string, Device> = {};
errorHandler?: (e: DOMException) => void;
created() {} created() {}
@ -137,6 +138,7 @@ class Devices extends Vue implements GenericDevices {
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
this.errorHandler?.(e);
} }
if ('progress' in device) this.$delete(device, 'progress'); if ('progress' in device) this.$delete(device, 'progress');
device.queue.shift(); device.queue.shift();

View file

@ -93,7 +93,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue, Watch, Ref } from 'vue-property-decorator'; import { Component, Ref, Vue, Watch } from 'vue-property-decorator';
import CalcInfo from 'n-link-core/components/CalcInfo.vue'; import CalcInfo from 'n-link-core/components/CalcInfo.vue';
import FileBrowser from 'n-link-core/components/FileBrowser.vue'; import FileBrowser from 'n-link-core/components/FileBrowser.vue';
import DeviceSelect from 'n-link-core/components/DeviceSelect.vue'; import DeviceSelect from 'n-link-core/components/DeviceSelect.vue';
@ -120,6 +120,9 @@ export default class Home extends Vue {
mounted() { mounted() {
this.webUSB = !!(navigator as any).usb; this.webUSB = !!(navigator as any).usb;
this.$devices.errorHandler = (e: DOMException) => {
this.errorMessage.handleError(e, 'operation');
};
} }
@Watch('$devices.hasEnumerated') @Watch('$devices.hasEnumerated')