exception-handling

Stop ArrayOutOfBoundsException from halting program execution in Java

Im am currently developing an automated "test" class (running several individual tests on other classes in the same package). The aim of the test file is to show whether each test either passed or failed. Some of the files being tested are not written correctly creating an ArrayOutOfBoundsException when running the test, that produces my...

Try-Catch-Throw in the same Java class

Is it possible to catch a method in the current class the try-catch block is running on? for example: public static void arrayOutOfBoundsException(){ System.out.println("Array out of bounds"); } ..... public static void doingSomething(){ try { if(something[i] >= something_else); } catch (arrayOut...

What's the best practice in case something goes wrong in Perl code?

Possible Duplicates: How can I cleanly handle error checking in Perl? Whats broken about exceptions in Perl? I saw code which works like this: do_something($param) || warn "something went wrong\n"; and I also saw code like this: eval { do_something_else($param); }; if($@) { warn "something went wrong\n"; } Should ...

Implementing traceback on i386

Hi, I am currently porting our code from an alpha (Tru64) to an i386 processor (Linux) in C. Everything has gone pretty smoothly up until I looked into porting our exception handling routine. Currently we have a parent process which spawns lots of sub processes, and when one of these sub-processes fatal's (unfielded) I have routines to ...

How are exceptions allocated on the stack caught beyond their scope?

In the following code, the stack-based variable 'ex' is thrown and caught in a function beyond the scope in which ex was declared. This seems a bit strange to me, since (AFAIK) stack-based variables cannot be used outside the scope in which they were declared (the stack is unwound). void f() { SomeKindOfException ex(...); throw ...

Questions regarding ordering of catch statements in catch block - compiler specific or language standard?

I am currently using Visual Studio Express C++ 2008, and have some questions about catch block ordering. Unfortunately, I could not find the answer on the internet so I am posing these questions to the experts. I notice that unless catch (...) is placed at the end of a catch block, the compilation will fail with error C2311. For example...

Where is this exception caught and handled?

In some code I've been reading, I've come across this : class Someclass { public static void main(String[] args) throws IOException { //all other code here...... } } If main() throws an exception, in this case its an IOException, where is it caught and handled? EDIT: Is this considered bad pract...

Suppress-catch or throw exceptions which can never occur?

Say I have the following line in a method: String encodedString = URLEncoder.encode(foo, "utf-8"); this method throws an UnsupportedEncodingException. Which is better: /** @throws UnsupportedEncodingException umm...never */ public void myMethod() throws UnsupportedEncodingException { ... String encodedString = URLEncoder.enco...

Why is the Catch(Exception) almost always a bad Idea?

Why is the Catch(Exception) almost always a bad Idea? ...

LINQ Iterator Exception Handling

var trimmed = myStringArray.Select(s => s.Substring(0, 10)); If one of the strings isn't 10 characters long I'd get an ArgumentOutOfRangeException. In this case its fairly trivial to find out and I know I can do s.Substring(0, Math.Min(10, s.Length)) With more complex object construction errors like this aren't always easy to se...

How do I catch the exception in windows application in c#?

Where should we catch exception In Layer Boundary (UI->BLL & BLL->DAL) In that methods where there is no interaction between Layers only some business logic present How do I write exception in Save/Delete where some DML statement executing? What should I write in DAL end? What should I write in BLL end? What should I write in UI e...

Using Enterprise Library Exception Handling Application Block in C#

I am using Enterprise Library Exception Handling Application Block. I have created a Policy, an Exception and a Custom Handler. Should my custom handler handle specific exception or system exception or both? ...

How do we catch Exception using Enterprise Library Exception Handling Application Block

I am using Enterprise Library Exception Handling Application Block. I have created a Policy, an Exception and a Custom Handler. Should my custom handler handle specific exception or system exception or both? ...

How to catch a FtpWebResponse exception in C#

I am building an FTP utility class in C#. In the case that a WebException is thrown on a call to FtpWebRequest.GetResponse(), in my case the exception is thrown for the requested file not existing on the remote server the FtpWebResponse variable is out of scope. But even if I declare the variable outside the try..catch block I get a co...

Exceptions are not caught in GCC program

My project contains shared library and exe client. I found that my own exception class thrown from the library is not caught by client catch block, and program terminates with "terminate called after throwing an instance of ..." message. Continuing to play with the project, I found that any exception of any type is not caught. For exampl...

File Load Exception on application startup

My application has encountered a problem and needs to close. Of course Microsoft is sorry for the inconvenience, but how am i supposed to debug my app? Which dll fails to load? The error report contains between others, system.io.fileloadexception How do you handle situations like these? ...

How and where do we write try catch block to handle Exception

We are using C# language to develope a Windows application. Our windows application consists of three layers (UI,Business and DataAccess layer). In Business Layer there are some public (business) methods through which UI communicates wilh Business layer classes. These public methods also have some private methods to implement the requir...

What is the difference between trapping and handling an exception?

I'm looking into exception handling in python and a blog post I read differentiated between trapping and handling an exception. Can someone explain the core difference between these two, both in python specifically and the overall conceptual difference? A google search for 'exception trapping handling' isn't super-useful. ...

Do I specify exception types in just the function header or declarations as well? (C++)

SVector.H: void pop_back() throw (underflow_error); In my SVector.cpp file, should I also include the throw (underflow_error) part as well? void pop_back() throw (underflow_error) { // implementation } OR void pop_back() { // implementation } Thanks. ...

Why do I use Tracing for logging exception in TextFile

Why do I use Tracing for logging exception in TextFile? What is the advantage of using trace over simple log while I am logging in text file. ...