Skip to content

Commit

Permalink
added example for low level error event
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 17, 2012
1 parent 8b8ca43 commit 986c346
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
5 changes: 5 additions & 0 deletions lib/Mojo/IOWatcher.pm
Expand Up @@ -180,6 +180,11 @@ L<Mojo::IOWatcher> can emit the following events.
Emitted safely if an error happens.
$watcher->on(error => sub {
my ($watcher, $err) = @_;
say "Something very bad happened: $err";
});
=head1 METHODS
L<Mojo::IOWatcher> inherits all methods from L<Mojo::EventEmitter> and
Expand Down
11 changes: 3 additions & 8 deletions lib/Mojolicious.pm
Expand Up @@ -151,8 +151,8 @@ sub handler {

# Embedded application
my $stash = {};
if ($tx->can('stash')) {
$stash = $tx->stash;
if (my $sub = $tx->can('stash')) {
$stash = $tx->$sub;
$tx = $tx->tx;
}

Expand All @@ -166,12 +166,7 @@ sub handler {

# Dispatcher
unless ($self->{dispatch}) {
$self->hook(
around_dispatch => sub {
my ($next, $c) = @_;
$c->app->dispatch($c);
}
);
$self->hook(around_dispatch => sub { shift; $c->app->dispatch(@_) });
$self->{dispatch}++;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -337,9 +337,9 @@ sub _dispatch_controller {

# Call action
my $stash = $c->stash;
if (my $code = $app->can($method)) {
if (my $sub = $app->can($method)) {
$stash->{'mojo.routed'}++ unless $staging;
$continue = $app->$code;
$continue = $app->$sub;
}

# Render
Expand All @@ -351,8 +351,8 @@ sub _dispatch_controller {

# Application
else {
if (my $code = $app->can('routes')) {
my $r = $app->$code;
if (my $sub = $app->can('routes')) {
my $r = $app->$sub;
weaken $r->parent($c->match->endpoint)->{parent} unless $r->parent;
}
$app->handler($c);
Expand Down
16 changes: 7 additions & 9 deletions lib/Mojolicious/Routes/Pattern.pm
@@ -1,16 +1,14 @@
package Mojolicious::Routes::Pattern;
use Mojo::Base -base;

has defaults => sub { {} };
has format => sub {qr#\.([^/]+)$#};
has [qw/defaults reqs/] => sub { {} };
has format => sub {qr#\.([^/]+)$#};
has [qw/pattern regex/];
has quote_end => ')';
has quote_start => '(';
has relaxed_start => '.';
has reqs => sub { {} };
has symbol_start => ':';
has symbols => sub { [] };
has tree => sub { [] };
has quote_end => ')';
has quote_start => '(';
has relaxed_start => '.';
has symbol_start => ':';
has [qw/symbols tree/] => sub { [] };
has wildcard_start => '*';

# "This is the worst kind of discrimination. The kind against me!"
Expand Down

0 comments on commit 986c346

Please sign in to comment.