Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Exception handling in Http::Dispatch
Exception handling in Http::Dispatch [message #37935] Sat, 24 November 2012 10:32 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi,

After few weeks of playing with Skylark, there is one last troublesome part of it that I would like to improve. The way it catches exceptions in Dispatch method.

Current Situation is that SqlExc, AuthExc, BadRequestExc and general Exc are caught and user can react on them using virtual methods (SqlError, Unauthorized, BadRequest, InternalError). One problem I have with this is how these functions are defined: They only got one parameter, which is the Http instance where the error occurred. So the user can react, but doesn't now what the exception was... IMHO the functions could look like this:
	virtual void SqlError(Http& http, const SqlExc& e);
	virtual void InternalError(Http& http, const Exc& e);
	virtual void Unauthorized(Http& http, const AuthExc& e);
	virtual void BadRequest(Http& http, const BadRequestExc& e);


BTW: There is an error, BadRequestExc triggers Unauthorized() to be called instead of BadRequest().

Another thing related to this and probably even more important is that exceptions coming from template parser are caught as Exc and they are very hard to recognize and track down. I understand that "Internal server error" should not disclose what exactly the error was because it could reveal way too much informations about application internals. So the preferable way is probably to add another catch block, that would handle CParser::Error, possibly with its own virtual function TemplateError(Http&, const CParser::Error&). The errors from parser are not very informative anyway, but at least knowing that the exception came from a template would save user couple minutes of tracing the code trying to figure out what did he coded wrong before finally realizing that he forgot a parenthesis in template or something similarly stupid Wink

Any other ideas about this? I can supply patch if necessary (but it seems quite simple, so I assumed it is not needed Smile ).

Best regards,
Honza
Re: Exception handling in Http::Dispatch [message #37977 is a reply to message #37935] Mon, 26 November 2012 19:22 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
RFQA: http://www.ultimatepp.org/redmine/issues/355
Previous Topic: [contribution request] Linux multimonitor XRANDR support
Next Topic: true dynamic dispatching with Upp?
Goto Forum:
  


Current Time: Fri Mar 29 06:32:48 CET 2024

Total time taken to generate the page: 0.01758 seconds