Skip to content

Commit

Permalink
create Mayoi::Model::Constant::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
xaicron committed Oct 11, 2010
1 parent af808a2 commit 68a163e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -12,6 +12,7 @@ requires 'Try::Tiny';
requires 'parent';
requires 'Data::Util';
requires 'Object::Container';
requires 'HTTP::Status';

test_requires 'Test::mysqld';
test_requires 'Test::Fixture::DBI';
Expand Down
22 changes: 22 additions & 0 deletions lib/Mayoi/Model/Constant/Error.pm
@@ -0,0 +1,22 @@
package Mayoi::Model::Constant::Error;

use Exporter 'import';
use HTTP::Status qw/:constants/;

our @EXPORT_OK = qw(
BAD_REQUEST UNAUTHORIZED FORBIDDEN NOT_FOUND METHOD_NOT_ALLOWED
INTERNAL_SERVER_ERROR SERVICE_UNAVAILABLE
);
our %EXPORT_TAGS = (
all => [@EXPORT_OK],
);

sub BAD_REQUEST () { HTTP_BAD_REQUEST }
sub UNAUTHORIZED () { HTTP_UNAUTHORIZED }
sub FORBIDDEN () { HTTP_FORBIDDEN }
sub NOT_FOUND () { HTTP_NOT_FOUND }
sub METHOD_NOT_ALLOWED () { HTTP_METHOD_NOT_ALLOWED }
sub INTERNAL_SERVER_ERROR () { HTTP_INTERNAL_SERVER_ERROR }
sub SERVICE_UNAVAILABLE () { HTTP_SERVICE_UNAVAILABLE }

1;
15 changes: 15 additions & 0 deletions t/model/constant/error/export.t
@@ -0,0 +1,15 @@
use strict;
use warnings;
use Test::More;
use Mayoi::Model::Constant::Error qw/:all/;
use HTTP::Status qw/:constants/;

is BAD_REQUEST, HTTP_BAD_REQUEST, 'BAD_REQUEST';
is UNAUTHORIZED, HTTP_UNAUTHORIZED, 'UNAUTHORIZED';
is FORBIDDEN, HTTP_FORBIDDEN, 'FORBIDDEN';
is NOT_FOUND, HTTP_NOT_FOUND, 'NOT_FOUND';
is METHOD_NOT_ALLOWED, HTTP_METHOD_NOT_ALLOWED, 'METHOD_NOT_ALLOWED';
is INTERNAL_SERVER_ERROR, HTTP_INTERNAL_SERVER_ERROR, 'INTERNAL_SERVER_ERROR';
is SERVICE_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, 'SERVICE_UNAVAILABLE';

done_testing;
7 changes: 7 additions & 0 deletions t/model/constant/error/use.t
@@ -0,0 +1,7 @@
use strict;
use warnings;
use Test::More;

use_ok 'Mayoi::Model::Constant::Error';

done_testing;

0 comments on commit 68a163e

Please sign in to comment.