Saturday, August 23, 2008

Creative Error Messages

My brain is frying. While trying to figure out a bug in Taskerbot -- which mysteriously has assigned just SOME tasks of SOME viewers SOMEtimes to the mysterious userid 9 which does not even exist -- I finally gave up and decided to just remake the whole form/script and do it differently.

I originally coded it in the context of TKR which is such a pain in the butt because of the identity/privacy issues and not being able to just use the USERID all over the place like normal. tBot doesn't have that issue and is going to be standalone so I'm redoing it the way it oughtta be.

While I'm at it I redesigned the top border, and the footer, and so on.

Then I decided my error messages need to display more prettily.

Then I decided that if I'm going to be writing code I could at least be creative.

So my new rule is that all error messages have to be in some form of poetry. By default, haiku, but it could be something else.

This is my sense of humor. Users will have to live with it.



This is the code that calls it (inside a CFIF tag):


<cfset errtype="notice">
<cfset errdetail = "localtask_detail p=step3 IF check viewer tasker must be session identity">
<cfset errmsg = "Avast, Imposter!<br /> You're not tasker, nor viewer!<br /> We hoard it from you.">
<cfinclude template="localtask_error.cfm">

And this is the localtask_error.cfm template:

<cfparam name="errtype" type="string" default="notice">
<cfparam name="errdetail" type="string" default="no code defined">
<cfparam name="errmsg" type="string" default="Programmer failed you<br />No error detail is here<br />Sorry. Try again.">

<div align="center"><table width="600" style="border:0px solid black; color:666666; padding:0px; margin:5px; margin-top:50px; ">
<tr valign="middle"><td align="left">

<fieldset style="clear: both; font-size: 125%; border-color: 990000; background-color: ivory; border-width: 1px 2px 3px 2px; border-style: solid solid solid solid; padding: 30 15 20 20; margin: 4 4 4 4; font-family:Calibri,Candara,Trebuchet,sans-serif; color:black;">

<legend style="font-size: 85%; font-weight: normal; color: 990000; margin: 0 0 0 0; padding: 0 5px;"><span style="color:gray;">tBot TASKER</span>  
<cfif errtype is 'notice'><span style="color:990000; font-size:150%;">Notice</span> <span style="color:silver;">| Error | Omission</span>
<cfelseif errtype is 'omit'><span style="color:silver;">Notice | Error |</span> <span style=" font-size:150%; color:990000;">Omission</span>
<cfelseif errtype is 'error'><span style="color:silver;">Notice |</span> <span style=" font-size:150%; color:990000;">Error</span> <span style="color:silver;">| Omission</span>
</cfif>
</legend>

<cfoutput>

#errmsg#

<br />
<br/ >
~ dojobots
<br />
<br />
<br />
<small><span style="color:gray; font-size:80%;">#errdetail#</span></small>

</cfoutput>

</fieldset>
</td></tr></table>
</div>

While I was at it, I also replaced the main application file error template. This is the one that comes up for CFML or SQL errors (or just before the webserver reboots, or just after it has and the database isn't fully up yet again, or...) to be something a lot more cheerful than the last error page, for both TKR and TBOT:



PJ

No comments: