01: package com.bm.utils;
02:
03: /**
04: * A more detailed version of NullPointerException that contains information
05: * about what argument was null.
06: *
07: * @author Daniel Wiese
08: */
09: public class DetailedNullPointerException extends NullPointerException {
10: private static final long serialVersionUID = -2554279092032000569L;
11:
12: private final String argumentName_;
13:
14: /**
15: * Create an instance.
16: *
17: * @param argumentName
18: * The name of the argument that was null
19: * @param message
20: * The message to use in the exception
21: */
22: public DetailedNullPointerException(final String argumentName,
23: final String message) {
24:
25: super (message);
26: argumentName_ = argumentName;
27: }
28:
29: /**
30: * Create an instance.
31: *
32: * @param argumentName
33: * The name of the argument that was null
34: */
35: public DetailedNullPointerException(final String argumentName) {
36: this (argumentName, argumentName);
37: }
38:
39: /**
40: * Return the name of the argument that was null.
41: *
42: * @return The name of the argument
43: */
44: public String getArgumentName() {
45: return argumentName_;
46: }
47: }
|