Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
# Please see issue #6 (#6).
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioprog committed Jan 7, 2013
1 parent e1122c0 commit 57921e5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
22 changes: 12 additions & 10 deletions brokers/brookfclcgibroker.pas
Original file line number Diff line number Diff line change
Expand Up @@ -294,38 +294,40 @@ procedure TBrookCGIHandler.ShowRequestException(R: TResponse; E: Exception);
else
R.Content := BrookSettings.Page404;
R.Content := Format(R.Content, [ApplicationURL]);
R.SendContent;
Exit;
end;
if (BrookSettings.Page500 <> ES) and (E is EBrookHTTP500) and
(not R.HeadersSent) then
if (BrookSettings.Page500 <> ES) and (not R.HeadersSent) then
begin
R.Code := BROOK_HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR;
R.CodeText := 'Application error ' + E.ClassName;
R.ContentType := FormatContentType;
if FileExists(BrookSettings.Page500) then
begin
R.Contents.LoadFromFile(BrookSettings.Page500);
R.Content := Format(R.Content, [E.Message]);
R.Content := Format(R.Content, [E.Message, BrookDumpStack]);
end
else
if BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_APP_JSON then
R.Content := Format(BrookSettings.Page500,
[StringToJSONString(E.Message)])
[StringToJSONString(E.Message), StringToJSONString(BrookDumpStack(LE))])
else
R.Content := Format(BrookSettings.Page500, [E.Message]);
R.Content := Format(BrookSettings.Page500, [E.Message, BrookDumpStack]);
R.SendContent;
Exit;
end;
if BrookSettings.ShowStackTraceOnError and
((R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML)) then
if (R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) then
begin
VStr := TStringList.Create;
try
ExceptionToHTML(VStr, E, Title, Email, Administrator);
R.Content := R.Content + VStr.Text;
R.Content := VStr.Text;
R.SendContent;
finally
VStr.Free;
end;
end;
R.SendContent;
end;

initialization
Expand Down
22 changes: 12 additions & 10 deletions brokers/brookfclfcgibroker.pas
Original file line number Diff line number Diff line change
Expand Up @@ -285,38 +285,40 @@ procedure TBrookFCGIHandler.ShowRequestException(R: TResponse; E: Exception);
else
R.Content := BrookSettings.Page404;
R.Content := Format(R.Content, [ApplicationURL]);
R.SendContent;
Exit;
end;
if (BrookSettings.Page500 <> ES) and (E is EBrookHTTP500) and
(not R.HeadersSent) then
if (BrookSettings.Page500 <> ES) and (not R.HeadersSent) then
begin
R.Code := BROOK_HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR;
R.CodeText := 'Application error ' + E.ClassName;
R.ContentType := FormatContentType;
if FileExists(BrookSettings.Page500) then
begin
R.Contents.LoadFromFile(BrookSettings.Page500);
R.Content := Format(R.Content, [E.Message]);
R.Content := Format(R.Content, [E.Message, BrookDumpStack]);
end
else
if BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_APP_JSON then
R.Content := Format(BrookSettings.Page500,
[StringToJSONString(E.Message)])
[StringToJSONString(E.Message), StringToJSONString(BrookDumpStack(LE))])
else
R.Content := Format(BrookSettings.Page500, [E.Message]);
R.Content := Format(BrookSettings.Page500, [E.Message, BrookDumpStack]);
R.SendContent;
Exit;
end;
if BrookSettings.ShowStackTraceOnError and
((R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML)) then
if (R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) then
begin
VStr := TStringList.Create;
try
ExceptionToHTML(VStr, E, Title, Email, Administrator);
R.Content := R.Content + VStr.Text;
R.Content := VStr.Text;
R.SendContent;
finally
VStr.Free;
end;
end;
R.SendContent;
end;

initialization
Expand Down
22 changes: 12 additions & 10 deletions brokers/brookfclhttpappbroker.pas
Original file line number Diff line number Diff line change
Expand Up @@ -154,39 +154,41 @@ procedure TBrookHTTPServerHandler.ShowRequestException(R: TResponse; E: Exceptio
else
R.Content := BrookSettings.Page404;
R.Content := Format(R.Content, [ApplicationURL]);
R.SendContent;
Exit;
end;
if (BrookSettings.Page500 <> ES) and (E is EBrookHTTP500) and
(not R.HeadersSent) then
if (BrookSettings.Page500 <> ES) and (not R.HeadersSent) then
begin
R.Code := BROOK_HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR;
R.CodeText := 'Application error ' + E.ClassName;
R.ContentType := FormatContentType;
if FileExists(BrookSettings.Page500) then
begin
R.Contents.LoadFromFile(BrookSettings.Page500);
R.Content := Format(R.Content, [E.Message]);
R.Content := Format(R.Content, [E.Message, BrookDumpStack]);
end
else
if BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_APP_JSON then
R.Content := Format(BrookSettings.Page500,
[StringToJSONString(E.Message)])
[StringToJSONString(E.Message), StringToJSONString(BrookDumpStack(LE))])
else
R.Content := Format(BrookSettings.Page500, [E.Message]);
R.Content := Format(BrookSettings.Page500, [E.Message, BrookDumpStack]);
R.SendContent;
Exit;
end;
if BrookSettings.ShowStackTraceOnError and
((R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML)) then
if (R.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) or
(BrookSettings.ContentType = BROOK_HTTP_CONTENT_TYPE_TEXT_HTML) then
begin
VStr := TStringList.Create;
try
R.ContentType := FormatContentType;
ExceptionToHTML(VStr, E, Title, Email, Administrator);
R.Content := R.Content + VStr.Text;
R.Content := VStr.Text;
R.SendContent;
finally
VStr.Free;
end;
end;
R.SendContent;
end;

initialization
Expand Down
3 changes: 0 additions & 3 deletions core/brookutils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ TBrookSettings = record
Configuration: string;
{ Handles the application exceptions. }
OnError: TOnShowRequestException;
{ Show stack trace along with Page404 or Page500 }
ShowStackTraceOnError: Boolean
end;

var
Expand All @@ -80,7 +78,6 @@ TBrookSettings = record
AcceptsJSONContent: False;
Configuration: ES;
OnError: nil;
ShowStackTraceOnError: False;
);

{ Get the next pathinfo level. }
Expand Down

0 comments on commit 57921e5

Please sign in to comment.