Linked Questions

11 votes
4 answers
17k views

Possible Duplicate: Best practices for exception management in JAVA or C# I've read a question earlier today on stackoverflow and it made me think about what is the best practice for handling ...
uthomas's user avatar
  • 784
0 votes
3 answers
4k views

Possible Duplicate: Best practices for exception management in JAVA or C# I am using class libraries and I try to put maximum code in class libraries so that it can be reused in other projects. ...
user576510's user avatar
  • 5,925
770 votes
21 answers
365k views

Joshua Bloch in "Effective Java" said that Use checked exceptions for recoverable conditions and runtime exceptions for programming errors (Item 58 in 2nd edition) Let's see if I understand ...
Thang Pham's user avatar
  • 38.8k
15 votes
11 answers
4k views

Which is more efficient in Java: to check for bad values to prevent exceptions or let the exceptions happen and catch them? Here are two blocks of sample code to illustrate this difference: void ...
lilbyrdie's user avatar
  • 1,907
17 votes
5 answers
21k views

Why is it discouraged to throw a generic (java.lang.Exception) exception, when it is usually sufficient to handle most conditional failures within a method? I understand that if a method could throw ...
oldSkool's user avatar
  • 1,242
13 votes
4 answers
33k views

I am a C programmer and just learning some java recently because I am developing one android application. Currently I am in a situation. Following is the one. public Class ClassA{ public ClassA(); ...
Surjya Narayana Padhi's user avatar
22 votes
6 answers
3k views

I understand that this is a very broad question, but a short “it depends” kind of answer will not be accepted. Strategies are born to deal with broad issues. What issues should an application designer ...
Vlad Gudim's user avatar
  • 23.5k
9 votes
5 answers
30k views

If face a logic error error such (Expired user, invalid ID), then what is the best way to tell the parent method of this error from the following : 1- Throwing customized exception like the following ...
Raed Alsaleh's user avatar
  • 1,621
9 votes
4 answers
14k views

So I have two general questions about java in general. The first is when would one use a try/catch in the body of the method versus using throws exception in declaring the method? Here is a little ...
Kemosabe's user avatar
  • 321
9 votes
6 answers
3k views

I am currently reviewing a colleagues Java code, and I see a lot of cases where every single statement that may throw an exception being encapsulated in its own try/catch. Where the catch block all ...
Bjarke Freund-Hansen's user avatar
5 votes
4 answers
4k views

Suppose I have the following code: void foo() { /* ... */ try { bar(param1); } catch (MyException e) { /* ??? */ } } void bar(Object param1) throws MyException { /...
einpoklum's user avatar
  • 137k
2 votes
6 answers
4k views

In my application i have 100 classes and each class contains 4 methods each. I am using try catch for exception handling. I write try catch in each method , then there will be 400 try catch statement ...
Nithesh Narayanan's user avatar
5 votes
3 answers
9k views

I am beginning to learn Java and writing my first utility classes in java which are supposed to go in production. I am somewhat lost when it is coming to dealing with exceptions. Is there some ...
xyz's user avatar
  • 8,987
1 vote
5 answers
2k views

I have a piece of code where I capture all exceptions and throw one generic exception at the end. Something like this: try { // do something here } catch (Whatever e) { throw new MyException(e....
Pass's user avatar
  • 1,511
2 votes
5 answers
2k views

(Long time reader of SO, first time asking a q. I'm quite new to C# having been in the PHP/Ruby/Python world for many years so I apologise if this is a dopey question.) I'm doing some maintenance on ...
SimonF's user avatar
  • 834

15 30 50 per page