logto
logto copied to clipboard
feat(core,phrases): throw database error with meaningful message
Summary
Throw RequestError about DatabaseError with meaningful message
- e.g.
value too long for type character varying(128)
Testing
- [x] UTs
- Locally tested.

LOG-3669 Backend: Throw database error with meaningful message
Situation:
The updating API, such asPOST /api/users and PATCH /api/users/:userId, will throw unknown error if the parameter, such as `username` and `name` (full name), exceeds the max length that is limited by the declared type `varchar(n)` of related property (max length is `n`) in the database table.
(See logto-oi/logto/packages/schemas/tables/users.sql and logto-oi/logto/packages/schemas/tables/application.sql for more details about the max lengths of the properties.)
---
Target:
- Backend: Throw an error with a meaningful message when the property exceed its max length.
COMPARE TO master
Total Size Diff :chart_with_downwards_trend: -73 Bytes
Diff by File
| Name | Diff |
|---|---|
| packages/connector-mock-mail/package.json | 0 Bytes |
| packages/connector-mock-sms/package.json | 0 Bytes |
| packages/core/package.json | :chart_with_downwards_trend: -47 Bytes |
| packages/core/src/middleware/koa-slonik-error-handler.test.ts | :chart_with_downwards_trend: -392 Bytes |
| packages/core/src/middleware/koa-slonik-error-handler.ts | :chart_with_downwards_trend: -166 Bytes |
| packages/phrases/src/locales/en/errors.ts | :chart_with_downwards_trend: -79 Bytes |
| packages/phrases/src/locales/zh-cn/errors.ts | :chart_with_downwards_trend: -62 Bytes |
| pnpm-lock.yaml | :chart_with_downwards_trend: -819 Bytes |
Closed. We will check and throw errors using the guard and createdGuard generated by schemas.