-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eec189
commit cec35de
Showing
5 changed files
with
86 additions
and
79 deletions.
There are no files selected for viewing
82 changes: 11 additions & 71 deletions
82
dev-packages/e2e-tests/test-applications/solidstart/src/routes/client-error.tsx
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,75 +1,15 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
import type { ParentProps } from 'solid-js'; | ||
import { ErrorBoundary, createSignal, onMount } from 'solid-js'; | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
const [count, setCount] = createSignal(1); | ||
const [caughtError, setCaughtError] = createSignal(false); | ||
|
||
export default function ClientErrorPage() { | ||
return ( | ||
<SampleErrorBoundary> | ||
{caughtError() && ( | ||
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} /> | ||
)} | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="caughtErrorBtn" | ||
onClick={() => setCaughtError(true)} | ||
> | ||
Throw caught error | ||
</button> | ||
</div> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="errorBtn" | ||
onClick={() => { | ||
throw new Error('Uncaught error thrown from Solid Start E2E test app'); | ||
}} | ||
> | ||
Throw uncaught error | ||
</button> | ||
</div> | ||
</section> | ||
</SampleErrorBoundary> | ||
); | ||
} | ||
|
||
function Throw(props: { error: string }) { | ||
onMount(() => { | ||
throw new Error(props.error); | ||
}); | ||
return null; | ||
} | ||
|
||
function SampleErrorBoundary(props: ParentProps) { | ||
return ( | ||
<SentryErrorBoundary | ||
fallback={(error, reset) => ( | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1> | ||
<div class="flex items-center space-x-2 mb-4"> | ||
<code>{error.message}</code> | ||
</div> | ||
<button | ||
id="errorBoundaryResetBtn" | ||
class="border rounded-lg px-2 border-gray-900" | ||
onClick={() => { | ||
setCount(count() + 1); | ||
setCaughtError(false); | ||
reset(); | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</section> | ||
)} | ||
> | ||
{props.children} | ||
</SentryErrorBoundary> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="errorBtn" | ||
onClick={() => { | ||
throw new Error('Uncaught error thrown from Solid Start E2E test app'); | ||
}} | ||
> | ||
Throw uncaught error | ||
</button> | ||
</div> | ||
); | ||
} |
64 changes: 64 additions & 0 deletions
64
dev-packages/e2e-tests/test-applications/solidstart/src/routes/error-boundary.tsx
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,64 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
import type { ParentProps } from 'solid-js'; | ||
import { ErrorBoundary, createSignal, onMount } from 'solid-js'; | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
const [count, setCount] = createSignal(1); | ||
const [caughtError, setCaughtError] = createSignal(false); | ||
|
||
export default function ErrorBoundaryTestPage() { | ||
return ( | ||
<SampleErrorBoundary> | ||
{caughtError() && ( | ||
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} /> | ||
)} | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="caughtErrorBtn" | ||
onClick={() => setCaughtError(true)} | ||
> | ||
Throw caught error | ||
</button> | ||
</div> | ||
</section> | ||
</SampleErrorBoundary> | ||
); | ||
} | ||
|
||
function Throw(props: { error: string }) { | ||
onMount(() => { | ||
throw new Error(props.error); | ||
}); | ||
return null; | ||
} | ||
|
||
function SampleErrorBoundary(props: ParentProps) { | ||
return ( | ||
<SentryErrorBoundary | ||
fallback={(error, reset) => ( | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1> | ||
<div class="flex items-center space-x-2 mb-4"> | ||
<code>{error.message}</code> | ||
</div> | ||
<button | ||
id="errorBoundaryResetBtn" | ||
class="border rounded-lg px-2 border-gray-900" | ||
onClick={() => { | ||
setCount(count() + 1); | ||
setCaughtError(false); | ||
reset(); | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</section> | ||
)} | ||
> | ||
{props.children} | ||
</SentryErrorBoundary> | ||
); | ||
} |
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
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