Skip to content

Commit

Permalink
working on custom status page
Browse files Browse the repository at this point in the history
  • Loading branch information
Anniepoo committed Jun 6, 2016
1 parent f9b3f06 commit 41099b1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions custom_status_page.pl
Expand Up @@ -31,3 +31,30 @@
search box to locate the page you are looking for.
|}),
HTML).


:- http_handler(root(throws), throws_handler, []).

http:status_page(server_error(Error), _Context, HTML) :-
phrase(page([ title('Sorry Im Busted')
],
{|html(Error)||
<h1>Dang, an error happened</h1>
<p>Oh fudge, error <b>Error</b> happened.</p>
|}),
HTML).

throws_handler(_Request) :-
catch(
_ is 1 / 0,
E,
( debug(status_page, '~w', [E]),
throw(http_reply(server_error(E))))
).
% _ is 1 / 0.

http:status_page(Oops, _Context, _HTML) :-
gtrace,
debug(status_page, 'status ~w~n', [Oops]),
fail.

0 comments on commit 41099b1

Please sign in to comment.