TsgcHTTP_JWT_Server › Events › OnJWTException
Fired when an exception is raised while decoding or validating the token so the application can log the error.
property OnJWTException: TsgcHTTPJWTExceptionEvent;
// TsgcHTTPJWTExceptionEvent = procedure(Sender: TObject; aConnection: TsgcWSConnection; E: Exception) of object
Unassigned — the exception is swallowed silently and IsJWTTokenValid returns False.
Fires from the exception handler inside IsJWTTokenValid whenever the pipeline raises: malformed token that cannot be split, unsupported algorithm in the header, OpenSSL / HMAC error, etc. E is the exception instance (do not free it) and E.Message carries the reason. Use this hook to log validation failures; the exception is not re-raised, so the server continues to serve other requests normally and the current request will follow the Unauthorized path.
procedure TMyForm.sgcJWTException(Sender: TObject;
aConnection: TsgcWSConnection; E: Exception);
begin
Log('JWT validation failed: ' + E.ClassName + ' - ' + E.Message);
end;