KostasR 1 Posted December 28, 2020 Hello All, I would like to log errors. The TMARSActivation.RegisterInvokeError method in Server.Ignition seems to be suitable for this. It is called in the event of an error. But "AActivation.Method" is not assigned, so nothing is logged. Does anyone have any idea how AActivation.Method can be assigned? TMARSActivation.RegisterInvokeError( procedure (const AActivation: IMARSActivation; const AException: Exception; var AHandled: Boolean) var LErrorObj: TJSONObject; begin if Assigned(AActivation.Method) then ^^^^^^^^^^^^^^^^^^ begin LErrorObj := TJSONObject.Create; try LErrorObj.WriteStringValue('error', AException.Message); LErrorObj.WriteStringValue('resource', AActivation.Resource.Name); LErrorObj.WriteStringValue('method', AActivation.Method.Name); LErrorObj.AddPair('url', AActivation.URL.ToJSONObject); AActivation.Response.ContentType := 'application/json'; AActivation.Response.Content := LErrorObj.ToJSON; FThreadFileLog.Log(#13#10 + LErrorObj.ToString); AHandled := True; finally LErrorObj.Free; end; end; end ); Regards, Kostas Share this post Link to post
Andrea Magni 75 Posted January 18, 2021 Hi Kostas, the MARSWebServer demo has been created way before the InvokeError mechanism has been introduced. The resource takes care to send a 404 response when a URL is not matching a file system entry (no actual error is raised, a custom response is sent). This means it's unlikely you'll ever get to the InvokeError anonymous handler you registered. You have a chance to have it called if you are addressing a non existent resource (different from helloworld). If you will explain me your needs we may improve the demo or build a new one. Sincerely, Andrea Share this post Link to post