Handling Exceptions in a Middleware
my $status = 500; if ( $e->isa( 'MyBlog::X::BadParam' )) { $status = 400; } elsif ( $e->isa('MyBlog::X::NotFound' )) { $status = 404; } return [ $status, [ 'Content-Type' => 'text/plain' ], [ 'There was an error: '.$message ], ];