quick-addition-90714
11/02/2024, 1:17 PMbrief-egg-61061
11/02/2024, 1:17 PMbrief-egg-61061
11/02/2024, 1:17 PMjson { "id": 4000006, "text": "The provided credentials are invalid, check for spelling mistakes in your password or username, email address, or phone number.", "type": "error", "context": {} }
[Source: Kratos Self-Service Login Form Validation](https://www.ory.sh/docs/kratos/self-service/flows/user-login#login-form-validation) 2. Field level errors: These are specific to individual form fields. Example for a missing identifier: json { "id": 4000001, "text": "length must be >= 1, but got 0", "type": "error" }
[Source: Kratos Self-Service Login Form Validation](https://www.ory.sh/docs/kratos/self-service/flows/user-login#login-form-validation) 3. Request level errors: These occur when there's an issue with the overall request. The error messages typically include an id
, text
, and type
. Some errors may also include additional context. When implementing your login page, you should handle these errors appropriately. Here's a basic structure of how errors are returned: typescript // method level error err.response?.data?.ui.messages.forEach((message) => { console.log(message) }) // field level error err.response?.data?.ui.nodes.forEach(({ messages }) => { messages.forEach((message) => { console.log(message) }) }) // request level error if (err.response?.data?.error) { console.log(err.response.data.error) }
[Source: Kratos Custom UI Integration Basics](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#error-handling) It's important to note that the exact error messages may vary depending on the specific scenario and configuration. The examples provided here are just a few of the possible error messages you might encounter.quick-addition-90714
11/02/2024, 8:56 PMbrief-egg-61061
11/02/2024, 8:56 PMbrief-egg-61061
11/02/2024, 8:56 PMjson { "code": 500, "message": "some message", "reason": "some reason", "debug": "some debug info" }
[User-facing errors documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors) 2. Error structure: Kratos provides errors at different levels: - Request level errors - Method level errors - Field level errors Each error has a structure like this: json { "id": 1234, "text": "Some default text", "context": {} }
[Error handling documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#error-handling) 3. API Error Response: For API responses, Kratos uses a standard JSON API error format: json { "error": { "code": 404, "message": "The resource could not be found", "status": "Not Found", "reason": "User with ID 1234 does not exist.", "debug": "SQL field \"foo\" is not a bool.", "details": {}, "id": "", "request": "d7ef54b1-ec15-46e6-bccb-524b82c035e6" } }
[Kratos API Reference](https://www.ory.sh/docs/kratos/reference/api) For Ory Hydra: Hydra uses a similar error response format for its API: json { "error": "string", "error_description": "string", "error_hint": "The redirect URL is not allowed.", "error_debug": "string", "status_code": 401 }
[Hydra API Reference](https://www.ory.sh/docs/hydra/reference/api) Both Kratos and Hydra use similar error structures, but the exact error messages and codes may vary depending on the specific scenario and configuration. To implement custom error handling, you'll need to configure the error UI URL in your Ory setup and then create a custom error page that can parse and display these error messages appropriately. For a complete list of possible error messages and their meanings, you might need to refer to the specific documentation for each product or explore the API references in more detail.