about summary refs log tree commit diff
path: root/lib/presque/Role/Error.pm
blob: 8f9577665a58a0e9ed1d258955cc235c06ed4c91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package presque::Role::Error;

use Moose::Role;

sub http_error {
    my ( $self, $msg, $code ) = @_;
    $self->response->code( $code || 400 );
    $self->finish( JSON::encode_json { error => $msg } );
}

sub http_error_queue {
    my $self = shift;
    $self->http_error( 'queue name is missing', 404 );
}

sub http_error_content_type {
    my $self = shift;
    $self->http_error('content-type must be set to application/json');
}

1;