The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MVC::Neaf::Exception - Exception class for Not Even A Framework.

DESCRIPTION

Currently internal signalling or MVC::Neaf is based on the exception mechanism. To avoid collisions with user's exceptions or Perl errors, these internal exceptions are blessed into this class.

Please see the neaf_err() function in MVC::Neaf.

By convention, die nnn and die MVC::Neaf::Exception->new( nnn ) will be treated exactly the same by Neaf.

CAUTION. This file is mostly used internally by Neaf and may change with little to no warning. Please file a bug/feature request demanding a more stable interface if you plan to rely on it.

CAVEAT EMPTOR.

METHODS

new( $@ || 500, %options )

new( %options )

Returns a new exception object.

%options may include any keys as well as some Neaf-like control keys:

  • -status - alias for first argument. If starts with 3 digits, will result in a "http error page" exception, otherwise is reset to 500 and reason is updated.

  • -reason - details about what happened

  • -headers - array or hash of headers, just like that of a normal reply.

  • -location - indicates a redirection

  • -sudden - this was not an expected error (die 404 or redirect) This will automatically turn on if -status cannot be parsed.

  • -file - where error happened

  • -line - where error happened

  • -nocaller - don't try to determine error origin via caller

status()

Return error code.

is_sudden()

Tells whether error was unexpected.

EXPERIMENTAL. Name and meaning subject to change.

as_string()

Stringify.

Result will start with MVC::Neaf: if error was generated via die 404 or a redirect.

Otherwise it would look similar to the original -status.

make_reply( $request )

Returns a refault error HTML page.

The default page is guaranteen to contain the status as its one and only <span> element, the unique request-id as one and only <b> element, and the location (if any) as its one and only <i> element.

This page used to be a JSON but it turned out hard to debug when dealing with javascript.

reason()

Returns error message that was expected to cause the error.

file_and_line

Return " at /foo/bar line 42" suffix, if both file and line are available. Empty string otherwise.

TO_JSON()

Converts exception to JSON, so that it doesn't frighten View::JS.

LICENSE AND COPYRIGHT

This module is part of MVC::Neaf suite.

Copyright 2016-2023 Konstantin S. Uvarin khedin@cpan.org.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.