Skip to content

Commit d07bcdf

Browse files
committed
Error handling cleanup
1 parent b7a1e61 commit d07bcdf

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/ECER.Clients.PSPPortal/ECER.Clients.PSPPortal.Server/PspUser/ProfileEndpoints.cs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,33 @@ async Task<Results<Ok, BadRequest<PspRegistrationErrorResponse>>> (
5050
),
5151
ctx.RequestAborted);
5252

53-
if (!result.IsSuccess && result.Error.HasValue)
53+
if (!result.IsSuccess)
5454
{
55-
return TypedResults.BadRequest(new PspRegistrationErrorResponse
55+
var errorCode = PspRegistrationError.GenericError;
56+
57+
if (result.Error.HasValue)
5658
{
57-
ErrorCode = result.Error.Value switch
59+
errorCode = result.Error.Value switch
5860
{
59-
RegisterPspUserError.PostSecondaryInstitutionNotFound => PspRegistrationError
60-
.PostSecondaryInstitutionNotFound,
61-
RegisterPspUserError.PortalInvitationTokenInvalid => PspRegistrationError.PortalInvitationTokenInvalid,
62-
RegisterPspUserError.PortalInvitationWrongStatus => PspRegistrationError.PortalInvitationWrongStatus,
63-
RegisterPspUserError.BceidBusinessIdDoesNotMatch => PspRegistrationError.BceidBusinessIdDoesNotMatch,
64-
_ => PspRegistrationError.PostSecondaryInstitutionNotFound
65-
}
61+
RegisterPspUserError.PostSecondaryInstitutionNotFound
62+
=> PspRegistrationError.PostSecondaryInstitutionNotFound,
63+
64+
RegisterPspUserError.PortalInvitationTokenInvalid
65+
=> PspRegistrationError.PortalInvitationTokenInvalid,
66+
67+
RegisterPspUserError.PortalInvitationWrongStatus
68+
=> PspRegistrationError.PortalInvitationWrongStatus,
69+
70+
RegisterPspUserError.BceidBusinessIdDoesNotMatch
71+
=> PspRegistrationError.BceidBusinessIdDoesNotMatch,
72+
73+
_ => PspRegistrationError.GenericError
74+
};
75+
}
76+
77+
return TypedResults.BadRequest(new PspRegistrationErrorResponse
78+
{
79+
ErrorCode = errorCode
6680
});
6781
}
6882

@@ -106,7 +120,9 @@ public enum PspRegistrationError
106120
/// <summary>The invitation is not in correct status for registration</summary>
107121
PortalInvitationWrongStatus,
108122
/// <summary>The BCeID Business ID doesn't match expected value</summary>
109-
BceidBusinessIdDoesNotMatch
123+
BceidBusinessIdDoesNotMatch,
124+
/// <summary>A generic error occurred during registration</summary>
125+
GenericError
110126
}
111127

112128
/// <summary>

src/ECER.Clients.PSPPortal/ecer.clients.pspportal.client/src/components/pages/Dashboard.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ export default defineComponent({
9494
case "PostSecondaryInstitutionNotFound":
9595
this.router.replace("/access-denied");
9696
break;
97+
case "GenericError":
9798
default:
9899
this.router.replace("/generic-registration-error");
100+
break;
99101
}
100102
return;
101103
}

src/ECER.Clients.PSPPortal/ecer.clients.pspportal.client/src/types/openapi.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ declare namespace Components {
4848
| "PostSecondaryInstitutionNotFound"
4949
| "PortalInvitationTokenInvalid"
5050
| "PortalInvitationWrongStatus"
51-
| "BceidBusinessIdDoesNotMatch";
51+
| "BceidBusinessIdDoesNotMatch"
52+
| "GenericError";
5253
/**
5354
* Error response for PSP user registration failures. Returns only the error code for frontend handling.
5455
*/

0 commit comments

Comments
 (0)