Skip to content
Output JSON subroutines for Error::Pure.
Perl
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
examples
inc/Module
lib/Error/Pure/Output
t/Error-Pure-Output-JSON
xt/Error-Pure-Output-JSON
.gitignore
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.yml
Makefile.PL
README
SIGNATURE
TODO

README

NAME
    Error::Pure::Output::JSON - Output JSON subroutines for Error::Pure.

SYNOPSIS
     use Error::Pure::Output::JSON qw(err_json);
     print err_json(@errors);

SUBROUTINES
    "err_json(@errors)"
             JSON print of backtrace.
             When is set global variable $PRETTY, print pretty output.
             Returns JSON serialization of backtrace.

VARIABLES
    $PRETTY
             JSON pretty output flag. Possible values are 0 or 1.
             Default value is 0.

EXAMPLE1
     # Pragmas.
     use strict;
     use warnings;

     # Modules.
     use Error::Pure::Output::JSON qw(err_json);

     # Fictional error structure.
     my $err_hr = {
             'msg' => [
                     'FOO',
                     'KEY',
                     'VALUE',
             ],
             'stack' => [
                     {
                             'args' => '(2)',
                             'class' => 'main',
                             'line' => 1,
                             'prog' => 'script.pl',
                             'sub' => 'err',
                     }, {
                             'args' => '',
                             'class' => 'main',
                             'line' => 20,
                             'prog' => 'script.pl',
                             'sub' => 'eval {...}',
                     }
             ],
     };

     # Print out.
     print err_json($err_hr);

     # Output:
     # {"msg":["FOO","KEY","VALUE"],"stack":[{"sub":"err","prog":"script.pl","args":"(2)","class":"main","line":1},{"sub":"eval {...}","prog":"script.pl","args":"","class":"main","line":20}]}

EXAMPLE2
     # Pragmas.
     use strict;
     use warnings;

     # Modules.
     use Error::Pure::Output::JSON qw(err_json);

     # Set pretty output.
     $Error::Pure::Output::JSON::PRETTY = 1;

     # Fictional error structure.
     my $err_hr = {
             'msg' => [
                     'FOO',
                     'KEY',
                     'VALUE',
             ],
             'stack' => [
                     {
                             'args' => '(2)',
                             'class' => 'main',
                             'line' => 1,
                             'prog' => 'script.pl',
                             'sub' => 'err',
                     }, {
                             'args' => '',
                             'class' => 'main',
                             'line' => 20,
                             'prog' => 'script.pl',
                             'sub' => 'eval {...}',
                     }
             ],
     };

     # Print out.
     print err_json($err_hr);

     # Output:
     # {
     #    "msg" : [
     #       "FOO",
     #       "KEY",
     #       "VALUE"
     #    ],
     #    "stack" : [
     #       {
     #          "sub" : "err",
     #          "prog" : "script.pl",
     #          "args" : "(2)",
     #          "class" : "main",
     #          "line" : 1
     #       },
     #       {
     #          "sub" : "eval {...}",
     #          "prog" : "script.pl",
     #          "args" : "",
     #          "class" : "main",
     #          "line" : 20
     #       }
     #    ]
     # }

DEPENDENCIES
    Exporter, JSON, Readonly.

SEE ALSO
    Task::Error::Pure
        Install the Error::Pure modules.

    Error::Pure::Output::Text
        Output subroutines for Error::Pure.

REPOSITORY
    <https://github.com/tupinek/Error-Pure-Output-JSON>

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

    <http://skim.cz>

LICENSE AND COPYRIGHT
     © Michal Špaček 2013-2015
     BSD 2-Clause License

VERSION
    0.11

Something went wrong with that request. Please try again.