From: Marco Pessotto Date: Mon, 18 Jul 2016 20:58:18 +0000 (-0500) Subject: documentation patch (edited by jnap) X-Git-Tag: 5.90110~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=93dd50c3c1ec1b8ec6d1333e84db28e2449f65d1;hp=058e4074653139386299c58678cd852d10060056 documentation patch (edited by jnap) --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 5cebc60..b085a6c 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -3573,14 +3573,31 @@ sub setup_encoding { Hook to let you customize how encoding errors are handled. By default we just throw an exception. Receives a hashref of debug information. -Example: +Example of call: $c->handle_unicode_encoding_exception({ param_value => $value, error_msg => $_, - encoding_step => 'params', + encoding_step => 'params', }); +You can override this for custom handling of unicode errors. If you want a +custom response here, one approach is to throw an HTTP style exception: + + sub handle_unicode_encoding_exception { + my ($c, $params) = @_; + HTTP::Exception::BAD_REQUEST->throw(status_message=>$params->{error_msg}); + } + +Alternatively you can 'catch' the error, stash it and write handling code later +in your application: + + sub handle_unicode_encoding_exception { + my ($c, $params) = @_; + $c->stash(BAD_UNICODE_DATA=>$params); + return 1; + } + =cut sub handle_unicode_encoding_exception {