Genii Weblog

SNTT: A smarter error page

Thu 8 Jan 2009, 10:01 AM



by Ben Langhinrichs
Error resultsI have talked about this before a bit, but the error page for Genii Software's website (which comes up when you look for a page that doesn't exist) seems like a missed opportunity.  Today I took some steps to make it a bit more useful by auto-searching keywords and topics in the Midas Help database and the formulating links.  You can see the results by using a URL such as image which is a page that doesn't exist on our website.  The new error screen is shown at the right, and you will notice it has links to possible topics in the Midas Help db which match the term or a keyword.  I thought that I would take a rare chance to show some useful formula language, something I don't do in here often enough.  There is nothing here to astound the experts, but some of you who are not aware of how useful formula language can be for a website might be interested (see the formula below the image at the bottom).

This is computed text included as part of the $$ReturnGeneralError form.  Since that returns different sorts of errors, and I only care about the one, I start by using a temporary variable 
arg1, which becomes the not found design note, or "" if this is a different error.

Next, I put either a "" or the results of a partial text search of the 
FIND view in the MidasHelp.nsf database.  Note the very important [FailSilent], which ensures that a failed search will return "" rather than raising an error, which would be a nuisance to handle.  The results will be either "" or a list of values which match.  If you look at the results above, you can tell that methods such as the AppendGraphic method must use a keyword of "image" or something like it.

Finally, after ensuring that I won't have over 20 results (due to computed text issues as well as space considerations), add after eliminating duplicates and sorting the results, I am ready to create the HTML.  Note that I heavily use the feature in formula language that a formula such as 
"A"+("B":"C") will become the list "AB":"AC", which is how I first add the <a href part before each argument and then the text and ending of the a tag afterwards.  This is very powerful, but it takes some practice and trial and error.

There is more to come, such as using the same technique to make the Help topic pages have more dynamic Related Topics sections, and adding in search links on the error page, but I thought this might be useful for those somewhat new to web development or somewhat new to formula language and its strengths with lists.



arg1 := 
@If (@Begins(MessageString; "HTTP Web Server: Couldn't find design note - "); @Right(MessageString; @Length(MessageString)-45); "");
arg2 := @If (arg1 = """"@DbLookup("""":"MidasHelp.nsf""FIND"; arg1; "Subject"; [FailSilent]:[PartialMatch]));
arg3 := @Sort(@Unique(@If(@Elements(arg2) > 20; @Subset(arg2; 20); arg2)));
@If (arg3 = """<!-- No Midas Help match for '"+arg1+"' -->""<br><h3>Possible Midas Rich Text topic matches:</h3>"+@Implode(((("&nbsp;&nbsp;<a href=\"/showcase.nsf/MidasHelp?ReadForm&Focus=" + @ReplaceSubstring(arg3; " ""+")) + ("\">"+arg3)) + "</a>"); "<br>")+"<br><br>")


Of course, you probably don't want to provide links to the Midas Help database, but just a little tweaking would probably allow you to provide links to your Site map or product database or something else.  Good luck, and happy erroring!

Copyright © 2009 Genii Software Ltd.

What has been said:

No documents found