Skip to content

Commit

Permalink
added examples for different transaction errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 29, 2014
1 parent 39dffc8 commit 7877860
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/Mojo/Message.pm
Expand Up @@ -503,6 +503,15 @@ make sure it is not excessively large, there's a 10MB limit by default.
Get or set message error, an C<undef> return value indicates that there is no
error.
# Connection error
$msg->error({message => 'Connection refused'});
# Parser error
$msg->error({message => 'Maximum message size exceeded', advice => 413});
# 4xx/5xx response
$msg->error({message => 'Internal Server Error', code => 500});
=head2 every_cookie
my $cookies = $msg->every_cookie('foo');
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Transaction.pm
Expand Up @@ -19,7 +19,7 @@ sub client_close {
$res->error({message => 'Premature connection close'});
}

# 400/500
# 4xx/5xx
elsif ($res->is_status_class(400) || $res->is_status_class(500)) {
$res->error({message => $res->message, code => $res->code});
}
Expand Down

0 comments on commit 7877860

Please sign in to comment.