Saturday 15 March 2014

c# - Which standard exception throw if there is error in a middle of operation? -



c# - Which standard exception throw if there is error in a middle of operation? -

according rtfm shouldn't utilize exception straight throw. when re-factoring code changed of them to

invalidoperationexception if method phone call inadequate (wrong pre-requisites, time, state, etc); timeoutexeption whenever there timeout; argumentexception (and related - argumentnullexception , argumentoutofrangeexception) when method called wrong parameters;

however, stuck figure out exception most suitable when method did half of operation (so parameters , state ok), problem occurs (in case it's communication external device, when reports "omg error").

what standard exception should utilize (i don't want derive own) in case of middle-progress or finalizing exception? shouldn't hard question, ...

it depends on situation. if web service (or perchance website) throw 500 internal server error.

in c# wcf service in circumstances following:

throw new system.servicemodel.web.webfaultexception<string>( "descriptive error message", system.net.httpstatuscode.internalservererror);

c# vb.net exception c++-cli standards

No comments:

Post a Comment