-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta' into feat/components/loading
- Loading branch information
Showing
20 changed files
with
103 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,59 @@ | ||
<template> | ||
<slot v-if="!error$" /> | ||
<component | ||
:is="component" | ||
v-if="error" | ||
v-else | ||
class="pdap-flex-container-center h-[full]" | ||
:v-bind="params" | ||
> | ||
<h1>Oops, something went wrong!</h1> | ||
<p class="max-w-full" data-test="error-boundary-message"> | ||
If you keep seeing this message, please email | ||
<a href="mailto:[email protected]">[email protected]</a> for assistance. | ||
</p> | ||
</component> | ||
<slot v-else /> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
component: { | ||
type: String, | ||
default: 'div', | ||
}, | ||
}, | ||
data() { | ||
return { | ||
error: false, | ||
}; | ||
}, | ||
/* TODO: figure out how to cover this lifecycle method in tests */ | ||
errorCaptured(error) { | ||
this.interceptError(error); | ||
}, | ||
methods: { | ||
interceptError(error) { | ||
this.error = error; | ||
}, | ||
}, | ||
}; | ||
|
||
<script setup lang="ts"> | ||
import { ComponentPublicInstance, onErrorCaptured, ref } from 'vue'; | ||
import { PdapErrorBoundaryProps } from './types'; | ||
const props = withDefaults(defineProps<PdapErrorBoundaryProps>(), { | ||
component: 'div', | ||
onError: undefined, | ||
params: undefined, | ||
stopPropagation: false, | ||
}); | ||
interface PdapErrorEmitted { | ||
error: Error; | ||
vm: ComponentPublicInstance | null; | ||
info?: string; | ||
} | ||
const emits = defineEmits<{ | ||
(event: 'error', { error, vm, info }: PdapErrorEmitted): void; | ||
}>(); | ||
const error$ = ref<Error>(); | ||
const info$ = ref<string | undefined>(''); | ||
function interceptError( | ||
error: Error, | ||
vm: ComponentPublicInstance | null, | ||
info?: string | ||
) { | ||
error$.value = error; | ||
info$.value = info; | ||
props.onError?.(error, vm); | ||
emits('error', { error: error, vm, info }); | ||
if (props.stopPropagation) return false; | ||
} | ||
/* Impossible and unwise to try testing this, so we remove from the coverage report */ | ||
/* c8 ignore next 3 */ | ||
onErrorCaptured((err, vm, info) => { | ||
interceptError(err, vm, info); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as ErrorBoundary } from './PdapErrorBoundary.vue'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ComponentPublicInstance } from 'vue'; | ||
|
||
export interface PdapErrorBoundaryProps { | ||
component: string; | ||
onError?: ( | ||
error: Error, | ||
target?: ComponentPublicInstance | null | undefined | ||
) => void; | ||
params?: Record<string, string>; | ||
stopPropagation?: boolean; | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/components/FlexContainer/__snapshots__/flex-container.spec.ts.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.