Throwing error coding

Hi,

I'm working on a code where I can throw an error, but I'm just wondering is this the correct way to code it?

The idea here is to create a class where the NotImplementedError will be used as an error to be thrown

publicclass NotImplementedErrorextends Error

{

/**

* Constructs a NotImplementedError.

*/

public NotImplementedError()

{

super("Not implemented");

}

}

[775 byte] By [vopoa] at [2007-11-27 2:53:09]
# 1
Are you sure you want to extend Error? I think of Errors as coming from the JVM.
DrLaszloJamfa at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...
# 2
I thought by extending the error I can use it to extends to other classes, where I can throw the errors
vopoa at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...
# 3
I'm not sure what you mean. For example: why not extend Exception or RuntimeException?
DrLaszloJamfa at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...
# 4
Errors are irrecoverable by definition. Secondly what do you mean by extend?
kilyasa at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...
# 5

> The idea here is to create a class where the

> NotImplementedError will be used as an error to be

> thrown

Why not just use the already existing UnsupportedOperationException?

Other than that you should probably derive from RuntimeException rather than Error.

jschella at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...
# 6
Arrite I'll follow u guys suggestion.I realized it finally makes sense what u guys were saying to me.Thank you
vopoa at 2007-7-12 3:27:50 > top of Java-index,Java Essentials,Java Programming...