feat: error message when resume() did not find data
This commit is contained in:
parent
0c9d64c28c
commit
7b72595909
1 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,14 @@
|
||||||
export function resume<T = any>(id: string): T {
|
export function resume<T = any>(id: string): T {
|
||||||
return JSON.parse(document.querySelector<HTMLTextAreaElement>(`#${id}`)?.value ?? '')
|
const element = document.querySelector<HTMLTextAreaElement>(`#${id}`);
|
||||||
|
|
||||||
|
if (element?.value)
|
||||||
|
return JSON.parse(element.value)
|
||||||
|
|
||||||
|
throw Error(`The call resume('${id}') did not find any data.
|
||||||
|
Check that the following are correct:
|
||||||
|
- The Resumable component is used with correct props
|
||||||
|
- "data" prop is not undefined
|
||||||
|
- "${id}" is the "id" of the Resumable component
|
||||||
|
See examples: https://sr.ht/~ayoayco/astro-resume/#usage
|
||||||
|
Stack trace: `)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue