Skip to main content
added 136 characters in body
Source Link
Stephen C
  • 25.4k
  • 6
  • 67
  • 90

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions  . (theThe fact that this is "internal" to your code does not alter this). And you cannot reasonably infer that exceptions are in appropriate based on the proposed exception name ... @Jarrod Roberson note!)

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes""Yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then:

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions  (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then:

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions. (The fact that this is "internal" to your code does not alter this. And you cannot reasonably infer that exceptions are in appropriate based on the proposed exception name ... @Jarrod Roberson note!)

So the question is whether it is reasonable to declare a private exception class. To that I would say "Yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then:

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.
added 3 characters in body
Source Link
Stephen C
  • 25.4k
  • 6
  • 67
  • 90

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then:

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then:

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.
added 87 characters in body
Source Link
Stephen C
  • 25.4k
  • 6
  • 67
  • 90

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable. The

The only riderriders I would make is that if there is any chance that the exception might "leak", then you probably should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable. The only rider I would make is that if there is any chance that the exception might "leak", then you probably should declare it as public ... so that any javadoc for the exception appears in the published API documentation.

I'm going to assume that there are situations where it is reasonable to throw exceptions.

I'm also going to assume that this is a situation where it is reasonable to use exceptions (the fact that this is "internal" to your code does not alter this).

So the question is whether it is reasonable to declare a private exception class. To that I would say "yes", assuming that there is no existing exception class that is suitable.

The only riders I would make is that if there is any chance that the exception might "leak", then

  • you should declare a constructor so that the exception has a reason String, and
  • you should declare it as public ... so that any javadoc for the exception appears in the published API documentation.
Source Link
Stephen C
  • 25.4k
  • 6
  • 67
  • 90
Loading