mirror of
https://github.com/lights0123/n-link.git
synced 2024-12-22 10:15:27 +00:00
Error messages during passive operation
This commit is contained in:
parent
ac1a26a797
commit
4b90a1a8da
|
@ -41,6 +41,7 @@ export interface GenericDevices {
|
|||
devices: Record<string, Device>;
|
||||
enumerating: boolean;
|
||||
hasEnumerated: boolean;
|
||||
errorHandler?: (e: DOMException) => void;
|
||||
|
||||
enumerate(): Promise<void>;
|
||||
open(dev: string): Promise<void>;
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -93,6 +93,7 @@ class Devices extends Vue implements GenericDevices {
|
|||
enumerating = false;
|
||||
hasEnumerated = false;
|
||||
devices: Record<string, Device> = {};
|
||||
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();
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
</template>
|
||||
|
||||
<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 FileBrowser from 'n-link-core/components/FileBrowser.vue';
|
||||
import DeviceSelect from 'n-link-core/components/DeviceSelect.vue';
|
||||
|
@ -120,6 +120,9 @@ export default class Home extends Vue {
|
|||
|
||||
mounted() {
|
||||
this.webUSB = !!(navigator as any).usb;
|
||||
this.$devices.errorHandler = (e: DOMException) => {
|
||||
this.errorMessage.handleError(e, 'operation');
|
||||
};
|
||||
}
|
||||
|
||||
@Watch('$devices.hasEnumerated')
|
||||
|
|
Loading…
Reference in a new issue