fix(idnot): mapper 400->400 et 401->401 (évite 502) | ci: docker_tag=ext
All checks were successful
build-and-push-ext / build_push (push) Successful in 15s
All checks were successful
build-and-push-ext / build_push (push) Successful in 15s
This commit is contained in:
parent
4c3848ceea
commit
78b920a18b
@ -1,5 +1,6 @@
|
||||
import fetch from 'node-fetch';
|
||||
import { IdNotUser, ECivility, EOfficeStatus, EIdnotRole } from '../../types';
|
||||
import { ValidationError, UnauthorizedError, ExternalServiceError } from '../../types/errors';
|
||||
|
||||
export class IdNotService {
|
||||
static async exchangeCodeForTokens(code: string) {
|
||||
@ -31,7 +32,13 @@ export class IdNotService {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
|
||||
if (response.status === 400) {
|
||||
throw new ValidationError('Invalid authorization code received from IdNot');
|
||||
}
|
||||
if (response.status === 401) {
|
||||
throw new UnauthorizedError('Invalid IdNot client credentials');
|
||||
}
|
||||
throw new ExternalServiceError('IdNot', `Token exchange failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
|
Loading…
x
Reference in New Issue
Block a user