Skip to content

Commit

Permalink
Merge pull request #473 from btomaj/main
Browse files Browse the repository at this point in the history
Fix Remix redirect on bounce
  • Loading branch information
paulomarg authored Oct 24, 2023
2 parents cf3f3f4 + ea8af64 commit edb9956
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tender-rings-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/shopify-app-remix': patch
---

Fixed the errorBoundary to work with new cases in Remix v2.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ describe('Error boundary', () => {
);
});

it('returns a string when handling an ErrorResponseImpl', () => {
// WHEN
const result = boundary.error(new ErrorResponseImpl());

// THEN
expect(result).toEqual(
<div dangerouslySetInnerHTML={{__html: 'Handling response'}} />,
);
});

it('throws an error when handling an unknown error', () => {
// WHEN
const result = () => boundary.error(new Error());
Expand All @@ -23,3 +33,4 @@ describe('Error boundary', () => {
});

class ErrorResponse extends Error {}
class ErrorResponseImpl extends Error {}
5 changes: 4 additions & 1 deletion packages/shopify-app-remix/src/server/boundary/error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export function errorBoundary(error: any) {
if (error.constructor.name === 'ErrorResponse') {
if (
error.constructor.name === 'ErrorResponse' ||
error.constructor.name === 'ErrorResponseImpl'
) {
return (
<div
dangerouslySetInnerHTML={{__html: error.data || 'Handling response'}}
Expand Down

0 comments on commit edb9956

Please sign in to comment.