You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Edvin Syse <ed...@sysedata.no> on 2008/03/10 10:10:39 UTC

Custom Exception/Error page

Hi. In my application I do:

		getApplicationSettings().setInternalErrorPage(ErrorPage.class);
getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); 


to display a custom page for error messages. I would also like to email 
myself the exception - is it possible that I can get a hold of the 
throwable from the ErrorPage.class, or do I have to explicitly catch and 
rethrow a RestartResponseException to obtain the exception?

-- Edvin



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


Re: Custom Exception/Error page

Posted by Sebastiaan van Erk <se...@sebster.com>.
Logging stuff in endless loops is generally a good way to blow things 
up. ;-) I remember back in my university days a friend of mine did some 
logging on /tmp on 150 or so Sun workstations. It  went into an endless 
loop and all of the workstations became inaccessible (/tmp and virtual 
memory were connected, don't ask why, so login failed with an out of 
memory error :-))

What you can do in case your mail server doesn't throttle and protect 
you against DOS-attacks, is use log4j's triggering event evaluator and 
put throttling into that.

See:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SMTPAppender.html

and:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/spi/TriggeringEventEvaluator.html)

Thus by limiting your buffer size of the SMTPAppender and make sure you 
can only have N triggering events per hour, you can easily avoid this 
problem.

Good point though, Martijn. :-)

Regards,
Sebastiaan



Martijn Dashorst wrote:
> It is a really good way to blow up your exchange server... We had a
> bug somewhere that generated exceptions in an endless loop. It took
> exchange over a whole day to empty the queue.
> 
> Martijn
> 
> On 3/10/08, Edvin Syse <ed...@sysedata.no> wrote:
>> Wow, that's a very nice solution. Thanks :))
>>
>>  -- Edvin
>>
>>  Sebastiaan van Erk skrev:
>>
>>> I would say that the standard practice is probably to use your logging
>>  > subsystem to email you the exception.
>>  >
>>  > For example, if you are using log4j to log, you could add something like
>>  > this to your log4j.xml file:
>>  >
>>  >     <appender name="ERRORMAILER"
>>  >         class="org.apache.log4j.net.SMTPAppender">
>>  >         <param name="from" value="noreply@mydomain.com" />
>>  >         <param name="to" value="your@email.com" />
>>  >         <param name="subject" value="[mydomain] ERROR" />
>>  >         <param name="SMTPHost" value="localhost" />
>>  >         <param name="threshold" value="ERROR" />
>>  >         <layout class="org.apache.log4j.PatternLayout">
>>  >             <param name="ConversionPattern" value="%d %-5p - [%C:%L]
>>  > %m%n" />
>>  >         </layout>
>>  >     </appender>
>>  >
>>  > Regards,
>>  > Sebastiaan
>>  >
>>  >
>>  > Edvin Syse wrote:
>>  >> Hi. In my application I do:
>>  >>
>>  >>         getApplicationSettings().setInternalErrorPage(ErrorPage.class);
>>  >> getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
>>  >>
>>  >>
>>  >> to display a custom page for error messages. I would also like to
>>  >> email myself the exception - is it possible that I can get a hold of
>>  >> the throwable from the ErrorPage.class, or do I have to explicitly
>>  >> catch and rethrow a RestartResponseException to obtain the exception?
>>  >>
>>  >> -- Edvin
>>  >>
>>  >>
>>  >>
>>  >> ---------------------------------------------------------------------
>>  >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>  >> For additional commands, e-mail: users-help@wicket.apache.org
>>  >>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>  For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

Re: Custom Exception/Error page

Posted by Martijn Dashorst <ma...@gmail.com>.
It is a really good way to blow up your exchange server... We had a
bug somewhere that generated exceptions in an endless loop. It took
exchange over a whole day to empty the queue.

Martijn

On 3/10/08, Edvin Syse <ed...@sysedata.no> wrote:
> Wow, that's a very nice solution. Thanks :))
>
>  -- Edvin
>
>  Sebastiaan van Erk skrev:
>
> > I would say that the standard practice is probably to use your logging
>  > subsystem to email you the exception.
>  >
>  > For example, if you are using log4j to log, you could add something like
>  > this to your log4j.xml file:
>  >
>  >     <appender name="ERRORMAILER"
>  >         class="org.apache.log4j.net.SMTPAppender">
>  >         <param name="from" value="noreply@mydomain.com" />
>  >         <param name="to" value="your@email.com" />
>  >         <param name="subject" value="[mydomain] ERROR" />
>  >         <param name="SMTPHost" value="localhost" />
>  >         <param name="threshold" value="ERROR" />
>  >         <layout class="org.apache.log4j.PatternLayout">
>  >             <param name="ConversionPattern" value="%d %-5p - [%C:%L]
>  > %m%n" />
>  >         </layout>
>  >     </appender>
>  >
>  > Regards,
>  > Sebastiaan
>  >
>  >
>  > Edvin Syse wrote:
>  >> Hi. In my application I do:
>  >>
>  >>         getApplicationSettings().setInternalErrorPage(ErrorPage.class);
>  >> getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
>  >>
>  >>
>  >> to display a custom page for error messages. I would also like to
>  >> email myself the exception - is it possible that I can get a hold of
>  >> the throwable from the ErrorPage.class, or do I have to explicitly
>  >> catch and rethrow a RestartResponseException to obtain the exception?
>  >>
>  >> -- Edvin
>  >>
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  >> For additional commands, e-mail: users-help@wicket.apache.org
>  >>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.1 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.1

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


Re: Custom Exception/Error page

Posted by Edvin Syse <ed...@sysedata.no>.
Wow, that's a very nice solution. Thanks :))

-- Edvin

Sebastiaan van Erk skrev:
> I would say that the standard practice is probably to use your logging 
> subsystem to email you the exception.
> 
> For example, if you are using log4j to log, you could add something like 
> this to your log4j.xml file:
> 
>     <appender name="ERRORMAILER"
>         class="org.apache.log4j.net.SMTPAppender">
>         <param name="from" value="noreply@mydomain.com" />
>         <param name="to" value="your@email.com" />
>         <param name="subject" value="[mydomain] ERROR" />
>         <param name="SMTPHost" value="localhost" />
>         <param name="threshold" value="ERROR" />
>         <layout class="org.apache.log4j.PatternLayout">
>             <param name="ConversionPattern" value="%d %-5p - [%C:%L] 
> %m%n" />
>         </layout>
>     </appender>
> 
> Regards,
> Sebastiaan
> 
> 
> Edvin Syse wrote:
>> Hi. In my application I do:
>>
>>         getApplicationSettings().setInternalErrorPage(ErrorPage.class);
>> getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); 
>>
>>
>> to display a custom page for error messages. I would also like to 
>> email myself the exception - is it possible that I can get a hold of 
>> the throwable from the ErrorPage.class, or do I have to explicitly 
>> catch and rethrow a RestartResponseException to obtain the exception?
>>
>> -- Edvin
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>

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


Re: Custom Exception/Error page

Posted by Sebastiaan van Erk <se...@sebster.com>.
I would say that the standard practice is probably to use your logging 
subsystem to email you the exception.

For example, if you are using log4j to log, you could add something like 
this to your log4j.xml file:

	<appender name="ERRORMAILER"
		class="org.apache.log4j.net.SMTPAppender">
		<param name="from" value="noreply@mydomain.com" />
		<param name="to" value="your@email.com" />
		<param name="subject" value="[mydomain] ERROR" />
		<param name="SMTPHost" value="localhost" />
		<param name="threshold" value="ERROR" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p - [%C:%L] %m%n" />
		</layout>
	</appender>

Regards,
Sebastiaan


Edvin Syse wrote:
> Hi. In my application I do:
> 
>         getApplicationSettings().setInternalErrorPage(ErrorPage.class);
> getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); 
> 
> 
> to display a custom page for error messages. I would also like to email 
> myself the exception - is it possible that I can get a hold of the 
> throwable from the ErrorPage.class, or do I have to explicitly catch and 
> rethrow a RestartResponseException to obtain the exception?
> 
> -- Edvin
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>