TsgcWSAPIServer_WebAuthn › Eventi › OnWebAuthnException
Viene attivato quando viene generata un'eccezione non gestita durante l'elaborazione di una richiesta WebAuthn; consente all'applicazione di registrare l'errore e di sovrascrivere il codice di risposta HTTP.
property OnWebAuthnException: TsgcWebAuthnOnExceptionEvent;
// TsgcWebAuthnOnExceptionEvent = procedure(Sender: TObject; E: Exception; var aResponseCode: Integer) of object
—
Si genera ogni volta che una richiesta di registrazione o autenticazione fallisce con un'eccezione non gestita. E è l'istanza dell'eccezione e aResponseCode è il codice di stato HTTP che il server restituirà (predefinito 500); modificarlo per mappare l'errore a uno stato più specifico come 400 o 403 quando appropriato. Utile per la registrazione centralizzata e per tradurre gli errori interni in un contratto HTTP stabile.
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;