TsgcWSAPIServer_WebAuthnEvents › OnWebAuthnException

OnWebAuthnException Event

Fires when an unhandled exception is raised while processing a WebAuthn request; lets the application log the error and override the HTTP response code.

Syntax

property OnWebAuthnException: TsgcWebAuthnOnExceptionEvent;
// TsgcWebAuthnOnExceptionEvent = procedure(Sender: TObject; E: Exception; var aResponseCode: Integer) of object

Default Value

Remarks

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.

Example

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;

Back to Events