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

NAME

GX::View::Error - Default error view

SYNOPSIS

    package MyApp::View::Error;
    
    use GX::View::Error;
    
    __PACKAGE__->setup(
        default_format   => 'html',
        default_encoding => 'utf-8'
    );
    
    1;

DESCRIPTION

This module provides the GX::View::Error class which extends the GX::View class.

METHODS

Constructor

new

Returns the view component instance.

    $view = $view_class->new;
Returns:
Exceptions:

Public Methods

All public methods can be called both as instance and class methods.

default_encoding

Returns the name of the default output encoding.

    $encoding = $view->default_encoding;
Returns:
  • $encoding ( string | undef )

    An encoding name, for example "utf-8" or "iso-8859-1", or undef if the default output encoding is not defined. See Encode for a list of supported encodings.

default_format

Returns the default render format.

    $format = $view->default_format;
Returns:
  • $format ( string | undef )

    A format identifier, for example "html", or undef if the default render format is not defined.

render

If called in void context, render() renders the given error message or exception object and adds the result to the body of the response object that is associated with the given context object. Additionally, it sets the "Content-Type" header of the response to an appropriate value, unless that header has already been set.

    $view->render( %arguments );
Arguments:
  • context ( GX::Context object ) [ required ]

    A context object. This argument is required in void context.

  • encoding ( string )

    The name of the desired output encoding, for example "utf-8" or "iso-8859-1". See Encode for a list of supported encodings. If omitted, the default encoding (or "utf-8" as the final fallback) will be applied.

  • error ( GX::Exception object | string )

    The exception object or error message to render. If omitted, the error attribute of the given context object or, if that attribute is undefined, a generic error message will be rendered.

  • format ( string )

    The desired render format. Defaults to the default render format. Currently, only "html" is supported out of the box.

Exceptions:

If called in non-void context, render() returns the rendered error message as a string of bytes.

    $output = $view->render( %arguments );
Arguments:
  • context ( GX::Context object )

    A context object. This argument is optional in non-void context.

  • encoding ( string )

    See above.

  • error ( GX::Exception object | string )

    See above.

  • format ( string )

    See above.

Returns:
  • $output ( byte string )

Exceptions:

setup

Sets up the view.

    $view->setup( %options );
Options:
  • default_encoding ( string )

    The name of the default output encoding, for example "utf-8" or "iso-8859-1". See Encode for a list of supported encodings. Defaults to the default encoding of the application.

  • default_format ( string )

    The default render format. Defaults to "html". Currently, only "html" is supported out of the box.

Exceptions:

SEE ALSO

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright (c) 2009-2011 Jörg A. Uzarek.

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