www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - d breaks execution on every error?

reply bobef <bobef_member pathlink.com> writes:
on every error my program breaks execution with some error
message. is there way to override this behavior?

exactly: when i pass wrong URI format (%ausdua) to std.uri.decode
i says "Error: URI error ". there are case where i can not
ensure right format or i want to allow errors (for instance - 
user input on web page)
Aug 05 2004
next sibling parent J C Calvarese <jcc7 cox.net> writes:
In article <ceu706$24sg$1 digitaldaemon.com>, bobef says...
on every error my program breaks execution with some error
message. is there way to override this behavior?

exactly: when i pass wrong URI format (%ausdua) to std.uri.decode
i says "Error: URI error ". there are case where i can not
ensure right format or i want to allow errors (for instance - 
user input on web page)

I think you need to use try/catch: http://www.digitalmars.com/d/statement.html#try I put an example here: http://www.dsource.org/tutorials/index.php?show_example=33 jcc7
Aug 05 2004
prev sibling parent Sean Kelly <sean f4.ca> writes:
In article <ceu706$24sg$1 digitaldaemon.com>, bobef says...
on every error my program breaks execution with some error
message. is there way to override this behavior?

exactly: when i pass wrong URI format (%ausdua) to std.uri.decode
i says "Error: URI error ". there are case where i can not
ensure right format or i want to allow errors (for instance - 
user input on web page)

The functions in std.utf throw exceptions on failure. To get around this you'll want to do something like this: # try { # decode( ... ); # } catch( UtfError e ) { # printf( "UTF Error: %.*s\n", e.toString() ); # } Sean
Aug 05 2004