TsgcWSAPIServer_WebAuthn › Events › OnWebAuthnException
Fires when an unhandled exception is raised while processing a WebAuthn request; lets the application log the error and override the HTTP response code.
property OnWebAuthnException: TsgcWebAuthnOnExceptionEvent;
// TsgcWebAuthnOnExceptionEvent = procedure(Sender: TObject; E: Exception; var aResponseCode: Integer) of object
—
Raised whenever a registration or authentication request fails with an unhandled exception. E is the exception instance and aResponseCode is the HTTP status code the server will return (default 500); change it to map the error to a more specific status such as 400 or 403 when appropriate. Useful for centralised logging and for translating internal errors into a stable HTTP contract.
procedure TForm1.sgcWSAPIServer_WebAuthn1WebAuthnException(Sender: TObject;
E: Exception; var aResponseCode: Integer);
begin
LogError('WebAuthn: ' + E.ClassName + ' - ' + E.Message);
if E is EsgcWebAuthn_InvalidRequest then
aResponseCode := 400;
end;