exception

Exception vs Throwable in Java

I know throw new Exception(); has a pretty large overhead, since it creates a full stackTrace, etc. Does throw new Throwable(); present the same problem? Is this behaviour inherited, or does throwing a Throwable has a smaller (o no) overhead? EDIT From an * annalist* point of view, a user inserting wrong password is an exception ...

Why does FormatException not inherit from ArgumentException?

Is there a known reason why FormatException does not inherit from ArgumentException? An invalid format would seem to be a very specific case of an argument being invalid, similar to ArgumentOutOfRangeException. The MSDN article for the class states: FormatException is thrown when the format of an argument in a method invocation doe...

Exception for an unentered value?

In my calculation app, which takes a few inputs and uses them in a fixed formula to produce multiple outputs, the application crashes if I try to run it without putting a value into every input. I know how to catch exceptions, but I don't know the name of the exception that would be thrown by this kind of error. Can anyone help me out o...

Do not show file paths in stack trace C#

Hi I am currently developing a C# application which has got it's own logging. When exceptions are thrown, the exception is saved into a list which can be viewed by the user via a list view. When the user clicks on a exception in the list view, the stack trace of the exception is shown in a text box. But even when I am executing the pro...

Is it okay that I sometimes sink my exceptions?

I have a best practices question. I realize this is subjective but wanted to ask people smarter than me if this is a common programming practice. If you have a method of something NON-CRITICAL that you don't want to interfere with the important functioning of your application, is it common to use an error sink like this? Try 'do ...

How to deal with accidental input of a double when using .nextInt() in Java?

So I am trying to deal with the possible exception of a user entering a double when my scanner is expecting integral input: boolean go = true; do { System.out.print("Please enter one grade from 0 - 100. To end input, enter a negative integral value.\n"); try { int myInt = scanner.nextInt(); ...

Why catch an exception as reference-to-const?

I've heard and read many times that's better to catch an exception as reference-to-const rather than as reference. Why is try { // stuff } catch (const std::exception& e) { // stuff } better than try { // stuff } catch (std::exception& e) { // stuff } ...

wcf service SecurityNegotiationException

Hi all, I am running a Simple Service on my Server with WCF; the service is hosted in WebDev.WebServer.exe (local). When I call the Service local I get the following exception: Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Secure channel cannot be opene d because security negotiation with the remote ...

Raising an exception vs printing?

Whats the difference between raising an exception and simply printing an error. For example, whats the benefit of using the following: if size < 0: raise ValueError('number must be non-negative') instead of simply: if size < 0: print 'number must be non-negative' I'm a newbie, please take it easy on me. :) ...

Connecting to a Multicast Server in Python

Hello This is my code for connecting to a multicast server, is this the best way of handling the exception. What I would like to do is to retry to connect if an exception occurs def initialiseMulticastTrackerComms(): try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.IPPROTO_IP, socket.IP_MUL...

Google Appengine and Python exceptions

In my Google Appengine application I have defined a custom exception InvalidUrlException(Exception) in the module 'gvu'. Somewhere in my code I do: try: results = gvu.article_parser.parse(source_url) except gvu.InvalidUrlException as e: self.redirect('/home?message='+str(e)) ... which works fine in the local GAE development se...

Java, read from file throws io exception - read error.

Hello all, Im reading from a file (data.bin) using the following approach - fis1 = new FileInputStream(file1); String data; dis1 = new DataInputStream(fis); buffread1=new BufferedReader(new InputStreamReader(dis1)); while( (data= buffread1.readLine())!=null){ } Now im getting the io exception of read error. Now im gue...

Common underflow and overflow exceptions

I am trying to get a hold of overflow and underflow exceptions in java, but couldn't get any nice tutorial. Specifically I wish to learn How are they different from each other? What are the subclasses of these exceptions? In which scenario they are thrown? Which of them can be handled and how? What are the best practice related to the...

java.net.SocketException: Connection Reset

I am running a client-server java code on my local machine n am connecting them using java sockets. I'm able to connect the client to the server and send a string of data, initially. When the server gets the data it also returns a string, initially. After that communication the whole thing just crashes. No response from both sides. I'...

InvalidCastException in VSTO add-in

I'm experiencing a bit weird problem with VSTO Outlook add-in I'm developing. It works fine on a bunch of machines but in one it throws an InvalidCastException and cannot find the reason why. I've checked that all prerequisites are installed on this machine (the installer doest it by itself but I also checked that manually) and everythin...

PageRequestManagerParserErrorException nightmares, fear

Hi all, I get PageRequestManagerParserErrorException error in my app: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Det...

C# question - how to populate a catch statement with the specific possible exceptions from the code in the try?

Hi, I'm using VS2008 and have ReSharper too. My question is how can I automate the creation of a try/catch block for which the catch is specifically populated with the possible exception from the try block? (i.e. not just put in an Exception ex) Background - Trying to help follow the best practice I read of "Don't catch (Exception...

Real time system exception handling

As always after some research I was unable to find anything of real value. My question is how does one go about handling exceptions in a real time system? As program failure generally is not the best case i.e. nuclear reactor/ heart monitor. Ok since everyone got lost on the second piece of this, which had NOTHING to do with the mai...

adding datalist into viewstate

I have added one datalist into view state as: ViewState["datalist"] = dtlstForm; and retrieved it as: DataList lis = (DataList)ViewState["datalist"]; then folowing error comes: Type 'System.Web.UI.WebControls.DataList' in Assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as seri...

How to catch Exception Message in Erlang?

This is the Exception message thrown by Gen_server when its not started. ([email protected])32> R11 = system_warning:self_test("SysWarn"). ** exception exit: {noproc, {gen_server,call, [system_warning_sup, {start_child, {system_warning_SysWarn, ...