diff --git a/src/resume.ts b/src/resume.ts index 20d796d..b15d133 100644 --- a/src/resume.ts +++ b/src/resume.ts @@ -1,3 +1,14 @@ export function resume(id: string): T { - return JSON.parse(document.querySelector(`#${id}`)?.value ?? '') + const element = document.querySelector(`#${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: `) }