Skip to content

Commit

Permalink
Widget displays the full error message on the SPA console (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ships committed Dec 14, 2023
1 parent e14d080 commit 952144a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/widget/src/docmap-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export function getSteps(docmapPerhaps: unknown): StepT[] {
const stepsMaybe = pipe(docmapPerhaps, Docmap.decode);

if (E.isLeft(stepsMaybe)) {
throw new TypeError(`Could not parse Docmap: ${JSON.stringify(docmapPerhaps)}`);
throw new TypeError(
`Could not parse Docmap: ${JSON.stringify(docmapPerhaps)}, found error: ${JSON.stringify(
stepsMaybe.left,
)}`,
);
}

const docmap = stepsMaybe.right;
Expand Down
7 changes: 4 additions & 3 deletions packages/widget/test/unit/docmap-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ test('getSteps when there are multiple steps', (t) => {

test('getSteps on non-docmaps', (t) => {
const notADocmap = { this: 'is', some: 'randomly', shaped: ['object'] };
const err = t.throws(() => getSteps(notADocmap), { instanceOf: TypeError });

t.is(err?.message, 'Could not parse Docmap: {"this":"is","some":"randomly","shaped":["object"]}');
t.throws(() => getSteps(notADocmap), {
instanceOf: TypeError,
message: /Could not parse Docmap: {"this":"is","some":"randomly","shaped":\["object"\]}/,
});
});

test('getSteps on docmaps without a first step', (t) => {
Expand Down

0 comments on commit 952144a

Please sign in to comment.