diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-07-15 15:24:59 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-07-23 23:45:29 +0200 |
| commit | a1b273e3cc84c5936c6d01e875e2000a823051f3 (patch) | |
| tree | 113bded8d17be0894869f30434c4a4dbc0d66954 | |
| parent | 0f6784f6acaf37069d4388e8cb27d200558a3de0 (diff) | |
teams: Report API validation errors.
* etc/teams.scm (<forgejo-validation-error>): New condition type.
(&forgejo-error)[api-error]: New field.
(define-forgejo-request): On 422, read the body as a
<forgejo-validation-error>.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
| -rwxr-xr-x | etc/teams.scm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/etc/teams.scm b/etc/teams.scm index 57d16988656..cacaa0e47fa 100755 --- a/etc/teams.scm +++ b/etc/teams.scm | |||
| @@ -133,6 +133,12 @@ exec $pre_inst_env_maybe guix repl -- "$0" "$@" | |||
| 133 | ;;; Forgejo support. | 133 | ;;; Forgejo support. |
| 134 | ;;; | 134 | ;;; |
| 135 | 135 | ||
| 136 | (define-json-mapping <forgejo-validation-error> | ||
| 137 | forgejo-validation-error forgejo-validation-error? | ||
| 138 | json->forgejo-validation-error | ||
| 139 | (message forgejo-validation-error-message) | ||
| 140 | (url forgejo-validation-error-url)) | ||
| 141 | |||
| 136 | ;; Forgejo team. This corresponds to both the 'Team' and 'CreateTeamOption' | 142 | ;; Forgejo team. This corresponds to both the 'Team' and 'CreateTeamOption' |
| 137 | ;; structures in Forgejo. | 143 | ;; structures in Forgejo. |
| 138 | (define-json-mapping <forgejo-team> | 144 | (define-json-mapping <forgejo-team> |
| @@ -204,7 +210,8 @@ exec $pre_inst_env_maybe guix repl -- "$0" "$@" | |||
| 204 | forgejo-error? | 210 | forgejo-error? |
| 205 | (url forgejo-error-url) | 211 | (url forgejo-error-url) |
| 206 | (method forgejo-error-method) | 212 | (method forgejo-error-method) |
| 207 | (response forgejo-error-response)) | 213 | (response forgejo-error-response) |
| 214 | (api-error forgejo-error-api-error)) | ||
| 208 | 215 | ||
| 209 | (define %codeberg-organization | 216 | (define %codeberg-organization |
| 210 | ;; Name of the organization at codeberg.org. | 217 | ;; Name of the organization at codeberg.org. |
| @@ -257,11 +264,15 @@ PARAMETERS." | |||
| 257 | (let ((value (deserialize port))) | 264 | (let ((value (deserialize port))) |
| 258 | (when port (close-port port)) | 265 | (when port (close-port port)) |
| 259 | value) | 266 | value) |
| 260 | (begin | 267 | (let ((error (and (= 422 (response-code response)) |
| 268 | port | ||
| 269 | (false-if-exception | ||
| 270 | (json->forgejo-validation-error port))))) | ||
| 261 | (when port (close-port port)) | 271 | (when port (close-port port)) |
| 262 | (raise (condition (&forgejo-error (url url) | 272 | (raise (condition (&forgejo-error (url url) |
| 263 | (method 'verb) | 273 | (method 'verb) |
| 264 | (response response))))))))) | 274 | (response response) |
| 275 | (api-error error))))))))) | ||
| 265 | ((_ (proc parameters ...) | 276 | ((_ (proc parameters ...) |
| 266 | docstring | 277 | docstring |
| 267 | (method components ...) | 278 | (method components ...) |
