Michal Špaček > Error-Pure-HTTP-JSON-0.03 > Error::Pure::HTTP::JSON::Advance

Download:
Error-Pure-HTTP-JSON-0.03.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Error::Pure::HTTP::JSON::Advance - Error::Pure module for JSON output with additional parameters over HTTP.

SYNOPSIS ^

 use Error::Pure::HTTP::JSON::Advance qw(err);
 err 'This is a fatal error', 'name', 'value';

SUBROUTINES ^

err(@messages)
 Process error in JSON format with messages @messages.
 Output affects $Error::Pure::Output::JSON::PRETTY variable.

EXAMPLE1 ^

 # Pragmas.
 use strict;
 use warnings;

 # Modules.
 use Error::Pure::HTTP::JSON::Advance qw(err);

 # Additional parameters.
 %Error::Pure::HTTP::JSON::Advance::ERR_PARAMETERS = (
         'status' => 1,
         'message' => 'Foo bar',
 );

 # Error.
 err '1';

 # Output like:
 # Content-type: application/json
 #
 # {"status":1,"error-pure":[{"msg":["1"],"stack":[{"sub":"err","prog":"example1.pl","args":"(1)","class":"main","line":17}]}],"message":"Foo bar"}

EXAMPLE2 ^

 # Pragmas.
 use strict;
 use warnings;

 # Modules.
 use Error::Pure::HTTP::JSON::Advance qw(err);

 # Additional parameters.
 %Error::Pure::HTTP::JSON::Advance::ERR_PARAMETERS = (
         'status' => 1,
         'message' => 'Foo bar',
 );

 # Error.
 err '1', '2', '3';

 # Output like:
 # Content-type: application/json
 #
 # {"status":1,"error-pure":[{"msg":["1","2","3"],"stack":[{"sub":"err","prog":"example2.pl","args":"(1, 2, 3)","class":"main","line":17}]}],"message":"Foo bar"}

EXAMPLE3 ^

 # Pragmas.
 use strict;
 use warnings;

 # Modules.
 use Error::Pure::Output::JSON;
 use Error::Pure::HTTP::JSON::Advance qw(err);

 # Additional parameters.
 %Error::Pure::HTTP::JSON::Advance::ERR_PARAMETERS = (
         'status' => 1,
         'message' => 'Foo bar',
 );

 # Pretty print.
 $Error::Pure::Output::JSON::PRETTY = 1;

 # Error.
 err '1';

 # Output like:
 # Content-type: application/json
 #
 # {
 #    "status" : 1,
 #    "error-pure" : [
 #       {
 #          "msg" : [
 #             "1"
 #          ],
 #          "stack" : [
 #             {
 #                "sub" : "err",
 #                "prog" : "example3.pl",
 #                "args" : "(1)",
 #                "class" : "main",
 #                "line" : 21
 #             }
 #          ]
 #       }
 #    ],
 #    "message" : "Foo bar"
 # }

DEPENDENCIES ^

Error::Pure::Utils, Error::Pure::Output::JSON, Exporter, List::MoreUtils, Readonly.

SEE ALSO ^

Error::Pure, Error::Pure::AllError, Error::Pure::Always, Error::Pure::Die, Error::Pure::Error, Error::Pure::ErrorList, Error::Pure::HTTP::AllError, Error::Pure::HTTP::Error, Error::Pure::HTTP::ErrorList, Error::Pure::HTTP::JSON, Error::Pure::HTTP::Print, Error::Pure::JSON, Error::Pure::JSON::Advance, Error::Pure::NoDie, Error::Pure::Output::JSON, Error::Pure::Output::Text, Error::Pure::Utils.

REPOSITORY ^

https://github.com/tupinek/Error-Pure-JSON

AUTHOR ^

Michal Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT ^

BSD license.

VERSION ^

0.03

syntax highlighting: