Error Code / Number ?

D

Dishan Fernando

Hi Group

is there any way to get the Error Code or Number related to the error ?
(Say within catch bolck)
Is java support that type of thing ?
What can i get from hashCode ?

Dishan
 
N

Niels Dybdahl

is there any way to get the Error Code or Number related to the error ?
(Say within catch bolck)
Is java support that type of thing ?

The catch statement can catch an object related to the object. This object
might have an embedded error number and it might not depending upon the
class. But it can be converted to a string message describing the error
(toString).

Niels Dybdahl
 
C

Chris Smith

Dishan Fernando said:
is there any way to get the Error Code or Number related to the error ?
(Say within catch bolck)
Is java support that type of thing ?

There is no general concept of an error code or error number in Java.
Instead, there are exception classes, which are far more functional,
since they can contain any kind of data you like. It would be very bad
form for any Java library to define and generate error numbers or error
codes, when it could have thrown exceptions instead.

However, there are some cases where error codes or numbers are available
for specific exceptions, especially when you're interacting with an
external resource that might provide an error code of some kind. For
example, SQLException has methods called getSQLState (returns a DBMS-
independent standard error code) and getErrorCode (return an internal
error code whose meaning depends on the DBMS, but which might be more
specific than the SQLState specification provides for.)
What can i get from hashCode ?

What you can get from hashCode is a relatively meaningless number, the
only guarantee about which is that if two objects return true from
"a.equals(b)", then their hashCode() implementations will return the
same number. Since exception subclasses typically will never return
true from "equals()" except when compared to themselves, this isn't
terribly useful to you. Hash codes are used in certain data structures
to store objects, but are not at all useful when attempting to interpret
objects.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top