Skip to content

Commit

Permalink
chore: camera error typings
Browse files Browse the repository at this point in the history
  • Loading branch information
aineo committed Jul 19, 2024
1 parent 54c09b8 commit ac715e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/components/QrcodeScannerDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default defineComponent({
cameras.value = await scanner.value.getCameras()
} catch (error) {
cameraStatus.value = 'nocamera'
onError(error as string)
onError(error as Error)
}
}
Expand All @@ -168,7 +168,7 @@ export default defineComponent({
show.value = false
}
const onError = (error: string) => {
const onError = (error: Error) => {
store.dispatch('snackbar/show', {
message: t('scan.something_wrong')
})
Expand Down Expand Up @@ -198,7 +198,7 @@ export default defineComponent({
cameraStatus.value = 'noaccess'
} else {
cameraStatus.value = 'nostream'
noStreamDetails.value = error
noStreamDetails.value = `${error.name} ${error.message}`
}
onError(error)
Expand Down
8 changes: 4 additions & 4 deletions src/lib/zxing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type DecodeContinuouslyCallback = (
controls?: IScannerControls
) => void

type ModalErrorCallback = (error: any) => void
type ModalErrorCallback = (error: Error) => void

export class Scanner {
cameraStream!: MediaStream
Expand All @@ -26,7 +26,7 @@ export class Scanner {
async start(
currentCamera: number | null,
decodeCallback: DecodeContinuouslyCallback,
modalCallback: ModalErrorCallback,
modalCallback: ModalErrorCallback
) {
// Stop all tracks from media stream before camera changing
if (this.cameraStream) this.stopVideoTracks()
Expand All @@ -42,8 +42,8 @@ export class Scanner {

this.codeReader.decodeFromVideoElement(this.videoElement, decodeCallback)
} catch (error) {
// If something went wrong, show the reason in modal window
modalCallback(error)
// If something went wrong, show the reason in the modal window
modalCallback(error as Error)
}
}

Expand Down

0 comments on commit ac715e4

Please sign in to comment.