Skip to content

Commit

Permalink
Merge pull request #505 from Kitware/report-global-errors
Browse files Browse the repository at this point in the history
Report global errors
  • Loading branch information
floryst authored Nov 15, 2023
2 parents 411e5a8 + e9dd799 commit 0d95bcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/components/DataSecurityBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {
errorReportingConfigured,
useErrorReporting,
} from '@/src/utils/errorReporting';
import { watch, ref } from 'vue';
import { computed } from 'vue';
const errorStore = useErrorReporting();
const reportingEnabled = ref(!errorStore.disableReporting);
watch(reportingEnabled, (enabled) => {
errorStore.disableReporting = !enabled;
const reportingEnabled = computed({
get: () => !errorStore.disableReporting,
set: (enabled) => {
errorStore.disableReporting = !enabled;
},
});
</script>

Expand Down
9 changes: 6 additions & 3 deletions src/composables/useGlobalErrorHook.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { onBeforeUnmount, onMounted } from 'vue';
import { captureException } from '@sentry/vue';
import { useMessageStore } from '../store/messages';

export function useGlobalErrorHook() {
const messageStore = useMessageStore();

const onError = (event: ErrorEvent) => {
console.error(event);
const details = event.error
? event.error
: { details: event.message ?? 'Unknown error' };
const errorMessage = event.message ?? 'Unknown global error';

captureException(event.error ?? errorMessage);

const details = event.error ? event.error : { details: errorMessage };
messageStore.addError('Application error (click for details)', details);
};

Expand Down

0 comments on commit 0d95bcb

Please sign in to comment.