Daraja HTTP Framework 3.5.0-SNAPSHOT
HTTP server framework for Object Pascal
Loading...
Searching...
No Matches
djErrorResponse.pas File Reference

Functions

 ResetResponse (TdjResponse Response)
 Resets a response that a Web Component or Web Filter may already have partly filled in, so that an error response can be built on a clean state.
 SetErrorResponse (TdjResponse Response, Exception E, const string ComponentName='')
 Replaces whatever a failed Web Component, Web Filter or handler left on the response with the framework's 500 error page.

Function Documentation

◆ ResetResponse()

ResetResponse ( TdjResponse Response)

Resets a response that a Web Component or Web Filter may already have partly filled in, so that an error response can be built on a clean state.

Clears the content (ContentText and ContentStream), every entity and response header field (ContentType, ContentLength, Location, ...) and CustomHeaders. Keeps the server name, the connection's keep-alive setting, and the cookies, because Indy stores a newly created session's cookie there.

Parameters
Responsethe response to reset. Its headers must not have been sent yet.

◆ SetErrorResponse()

SetErrorResponse ( TdjResponse Response,
Exception E,
const string ComponentName = '' )

Replaces whatever a failed Web Component, Web Filter or handler left on the response with the framework's 500 error page.

The page is generic and discloses nothing about the exception, unless DARAJA_PROJECT_STAGE_DEVELOPMENT is defined: then it shows the exception class and message, the component name, and a stack trace where available.

If the response headers were already sent (for example by a component that streams its output), the status can no longer change. The pending content is dropped and the connection is closed instead, so the client sees a truncated response rather than an error page appended to a partial body.

Parameters
Responsethe response to replace
Ethe exception that caused the error
ComponentNamethe Web Component that was handling the request, if known; shown only on the development page