TsgcWSAPIServer_WebAuthn › 事件 › OnWebAuthnException
当处理 WebAuthn 请求时抛出未处理异常时触发;允许应用程序记录错误并覆盖 HTTP 响应代码。
property OnWebAuthnException: TsgcWebAuthnOnExceptionEvent;
// TsgcWebAuthnOnExceptionEvent = procedure(Sender: TObject; E: Exception; var aResponseCode: Integer) of object
—
当注册或身份验证请求因未处理的异常而失败时触发。E 是异常实例,aResponseCode 是服务器将返回的 HTTP 状态码(默认 500);在适当时将其更改以将错误映射到更具体的状态,例如 400 或 403。适用于集中日志记录以及将内部错误转换为稳定的 HTTP 契约。
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;