You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bob Harner <bo...@gmail.com> on 2014/12/19 22:54:24 UTC

Custom error pages with actual messages

Hi everybody,

Whenever I follow the Error Page Recipe [1] to create custom a error
response page, everything works fine except that, to my knowledge, the
page can only have a fixed message. For example, my 403 error page
always says "Sorry, you can't have that". That's fine, but what if I
want my error pages to display the more specific underlying message?

For example, the Java class for one of my app's regular pages has the
following within an onActivate() method:

            return new HttpError(500, "The database just blew up");

which generates the proper 500 response to the container. Now, if I
have NOT configured a custom error response for status 500 in my
web.xml then my servlet container (Jetty, currently) dutifully
displays the specific message (the "reason") that was given:

            HTTP ERROR 500
            Problem accessing /foo. Reason:
            The database just blew up

But I would really like to make the text of that 3rd line ("The
database just blew up") visible within my (Tapestry) custom error
page. Is there any way to get it? I tried injecting the Response
object but it doesn't seem to contain anything I can use for this. I
could copy the message to the session before calling return new
HttpError(....) but -- yuk.

Thanks!

[1] http://tapestry.apache.org/error-page-recipe.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Custom error pages with actual messages

Posted by Kalle Korhonen <ka...@gmail.com>.
Right. Well, if it's 5.3.x, you could just as well use tynamo's
tapestry-exceptionpage as a dependency with everything else pretty much
equal.

Kalle

On Fri, Dec 19, 2014 at 5:50 PM, Bob Harner <bo...@gmail.com> wrote:
>
> No, sorry, it's 5.3.7. This particular project isn't ready to move to
> 5.4 yet. I had forgotten about your exception page additions to 5.4,
> thanks for the reminder. That's one of several new things in 5.4 that
> aren't yet well explained anywhere.
>
> On Fri, Dec 19, 2014 at 7:39 PM, Kalle Korhonen
> <ka...@gmail.com> wrote:
> > For 5.4? Use exceptions, not error codes and the new contributable
> > DefaultExceptionHandler. 5.4 contains a built-in a version of
> > tapestry-exceptionpage (see
> http://tynamo.org/tapestry-exceptionpage+guide,
> > you can map exceptions to specific pages with context). I've written the
> > javadocs for 5.4 but I have yet to revise the cwiki documentation (and
> you
> > are welcome to help/take charge of that since its your specialty - and
> > thanks for the 5.3.8 release notes btw).
> >
> > Kalle
> >
> > On Fri, Dec 19, 2014 at 1:54 PM, Bob Harner <bo...@gmail.com> wrote:
> >>
> >> Hi everybody,
> >>
> >> Whenever I follow the Error Page Recipe [1] to create custom a error
> >> response page, everything works fine except that, to my knowledge, the
> >> page can only have a fixed message. For example, my 403 error page
> >> always says "Sorry, you can't have that". That's fine, but what if I
> >> want my error pages to display the more specific underlying message?
> >>
> >> For example, the Java class for one of my app's regular pages has the
> >> following within an onActivate() method:
> >>
> >>             return new HttpError(500, "The database just blew up");
> >>
> >> which generates the proper 500 response to the container. Now, if I
> >> have NOT configured a custom error response for status 500 in my
> >> web.xml then my servlet container (Jetty, currently) dutifully
> >> displays the specific message (the "reason") that was given:
> >>
> >>             HTTP ERROR 500
> >>             Problem accessing /foo. Reason:
> >>             The database just blew up
> >>
> >> But I would really like to make the text of that 3rd line ("The
> >> database just blew up") visible within my (Tapestry) custom error
> >> page. Is there any way to get it? I tried injecting the Response
> >> object but it doesn't seem to contain anything I can use for this. I
> >> could copy the message to the session before calling return new
> >> HttpError(....) but -- yuk.
> >>
> >> Thanks!
> >>
> >> [1] http://tapestry.apache.org/error-page-recipe.html
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Custom error pages with actual messages

Posted by Bob Harner <bo...@gmail.com>.
No, sorry, it's 5.3.7. This particular project isn't ready to move to
5.4 yet. I had forgotten about your exception page additions to 5.4,
thanks for the reminder. That's one of several new things in 5.4 that
aren't yet well explained anywhere.

On Fri, Dec 19, 2014 at 7:39 PM, Kalle Korhonen
<ka...@gmail.com> wrote:
> For 5.4? Use exceptions, not error codes and the new contributable
> DefaultExceptionHandler. 5.4 contains a built-in a version of
> tapestry-exceptionpage (see http://tynamo.org/tapestry-exceptionpage+guide,
> you can map exceptions to specific pages with context). I've written the
> javadocs for 5.4 but I have yet to revise the cwiki documentation (and you
> are welcome to help/take charge of that since its your specialty - and
> thanks for the 5.3.8 release notes btw).
>
> Kalle
>
> On Fri, Dec 19, 2014 at 1:54 PM, Bob Harner <bo...@gmail.com> wrote:
>>
>> Hi everybody,
>>
>> Whenever I follow the Error Page Recipe [1] to create custom a error
>> response page, everything works fine except that, to my knowledge, the
>> page can only have a fixed message. For example, my 403 error page
>> always says "Sorry, you can't have that". That's fine, but what if I
>> want my error pages to display the more specific underlying message?
>>
>> For example, the Java class for one of my app's regular pages has the
>> following within an onActivate() method:
>>
>>             return new HttpError(500, "The database just blew up");
>>
>> which generates the proper 500 response to the container. Now, if I
>> have NOT configured a custom error response for status 500 in my
>> web.xml then my servlet container (Jetty, currently) dutifully
>> displays the specific message (the "reason") that was given:
>>
>>             HTTP ERROR 500
>>             Problem accessing /foo. Reason:
>>             The database just blew up
>>
>> But I would really like to make the text of that 3rd line ("The
>> database just blew up") visible within my (Tapestry) custom error
>> page. Is there any way to get it? I tried injecting the Response
>> object but it doesn't seem to contain anything I can use for this. I
>> could copy the message to the session before calling return new
>> HttpError(....) but -- yuk.
>>
>> Thanks!
>>
>> [1] http://tapestry.apache.org/error-page-recipe.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Custom error pages with actual messages

Posted by Kalle Korhonen <ka...@gmail.com>.
For 5.4? Use exceptions, not error codes and the new contributable
DefaultExceptionHandler. 5.4 contains a built-in a version of
tapestry-exceptionpage (see http://tynamo.org/tapestry-exceptionpage+guide,
you can map exceptions to specific pages with context). I've written the
javadocs for 5.4 but I have yet to revise the cwiki documentation (and you
are welcome to help/take charge of that since its your specialty - and
thanks for the 5.3.8 release notes btw).

Kalle

On Fri, Dec 19, 2014 at 1:54 PM, Bob Harner <bo...@gmail.com> wrote:
>
> Hi everybody,
>
> Whenever I follow the Error Page Recipe [1] to create custom a error
> response page, everything works fine except that, to my knowledge, the
> page can only have a fixed message. For example, my 403 error page
> always says "Sorry, you can't have that". That's fine, but what if I
> want my error pages to display the more specific underlying message?
>
> For example, the Java class for one of my app's regular pages has the
> following within an onActivate() method:
>
>             return new HttpError(500, "The database just blew up");
>
> which generates the proper 500 response to the container. Now, if I
> have NOT configured a custom error response for status 500 in my
> web.xml then my servlet container (Jetty, currently) dutifully
> displays the specific message (the "reason") that was given:
>
>             HTTP ERROR 500
>             Problem accessing /foo. Reason:
>             The database just blew up
>
> But I would really like to make the text of that 3rd line ("The
> database just blew up") visible within my (Tapestry) custom error
> page. Is there any way to get it? I tried injecting the Response
> object but it doesn't seem to contain anything I can use for this. I
> could copy the message to the session before calling return new
> HttpError(....) but -- yuk.
>
> Thanks!
>
> [1] http://tapestry.apache.org/error-page-recipe.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>