forked from ory/elements
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error handling for preact-spa 422 code (ory#74)
* fix: package.json build:preact script * fix: Error handling for 422 code (ory#53) * fix: Implement error handling * refactor: Replicate function flow from react * style: format * fix: format * feat: api call generic error handling * feat: add basic error page * fix: change default signupURL to /registration * fix: change /signup to default kratos /registration Co-authored-by: Alano Terblanche <[email protected]> Co-authored-by: Alano Terblanche <[email protected]>
- Loading branch information
Showing
10 changed files
with
474 additions
and
129 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useEffect, useState } from "preact/hooks" | ||
import { CodeBox, ButtonLink } from "@ory/elements-preact" | ||
import { getSearchParam } from "./sdk" | ||
|
||
export const Error = () => { | ||
const [error, setError] = useState<string>() | ||
|
||
useEffect(() => { | ||
const queryError = getSearchParam("error") | ||
|
||
if (queryError !== null) { | ||
try { | ||
setError( | ||
JSON.stringify(JSON.parse(decodeURIComponent(queryError)), null, 2), | ||
) | ||
} catch (error) { | ||
setError(queryError) | ||
} | ||
} else { | ||
setError("Undefined error") | ||
} | ||
}, []) | ||
|
||
// we check if the flow is set, if not we show a loading indicator | ||
return ( | ||
<> | ||
<ButtonLink href="/">Home</ButtonLink> | ||
|
||
<p> | ||
An error occurred. Please check the error information below and try | ||
again. | ||
</p> | ||
<CodeBox | ||
style={{ | ||
overflow: "auto", | ||
maxWidth: "600px", | ||
}} | ||
> | ||
{error} | ||
</CodeBox> | ||
</> | ||
) | ||
} |
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
Oops, something went wrong.