exception Error number???

  • Thread starter Thread starter perspolis
  • Start date Start date
P

perspolis

I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number when an
exeption arise.. and also I don't want to inherit that exception..
 
perspolis,

You mean the HRESULT that it stores? I would not store that, nor can I
think of a situation why you really need it. It doesn't uniquely identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?
 
I need Hresult to determin kind of exception and show user the apptopriate
message......
in some situations the exception is the same but the message are diffrent..i
need hresult to get the correct exeption
Nicholas Paldino said:
perspolis,

You mean the HRESULT that it stores? I would not store that, nor can I
think of a situation why you really need it. It doesn't uniquely identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

perspolis said:
I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number when
an
exeption arise.. and also I don't want to inherit that exception..
 
perspolis,

You shouldn't be depending on this, but rather, the type. The only
reason you should need the HRESULT is for types of COMException. All other
exceptions, the HRESULT isn't going to help much.

I would base these decisions on the type.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

perspolis said:
I need Hresult to determin kind of exception and show user the apptopriate
message......
in some situations the exception is the same but the message are
diffrent..i
need hresult to get the correct exeption
in
message news:[email protected]...
perspolis,

You mean the HRESULT that it stores? I would not store that, nor can I
think of a situation why you really need it. It doesn't uniquely
identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

perspolis said:
I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number when
an
exeption arise.. and also I don't want to inherit that exception..
 
but sometimes the exceptions type are the same with diffrent message..in
that situation how can i make a decision??
Nicholas Paldino said:
perspolis,

You shouldn't be depending on this, but rather, the type. The only
reason you should need the HRESULT is for types of COMException. All other
exceptions, the HRESULT isn't going to help much.

I would base these decisions on the type.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

perspolis said:
I need Hresult to determin kind of exception and show user the apptopriate
message......
in some situations the exception is the same but the message are
diffrent..i
need hresult to get the correct exeption
in
message news:[email protected]...
perspolis,

You mean the HRESULT that it stores? I would not store that, nor
can
I
think of a situation why you really need it. It doesn't uniquely
identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number when
an
exeption arise.. and also I don't want to inherit that exception..
 
perspolis,

Are you trying to say that you are making decisions in logic based on
exceptions? This is a bad idea to begin with. The idea of exceptions are
just that, exceptional cases. For example, if the logic is dependent on the
file existing, and you just open it, and get an exception, you shouldn't try
to determine whether or not the file existed from the exception. Rather,
you should check for the existence of the file first, and then try and open
it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


perspolis said:
but sometimes the exceptions type are the same with diffrent message..in
that situation how can i make a decision??
in
message news:eteI#[email protected]...
perspolis,

You shouldn't be depending on this, but rather, the type. The only
reason you should need the HRESULT is for types of COMException. All other
exceptions, the HRESULT isn't going to help much.

I would base these decisions on the type.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

perspolis said:
I need Hresult to determin kind of exception and show user the apptopriate
message......
in some situations the exception is the same but the message are
diffrent..i
need hresult to get the correct exeption
"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in
message perspolis,

You mean the HRESULT that it stores? I would not store that, nor can
I
think of a situation why you really need it. It doesn't uniquely
identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number
when
an
exeption arise.. and also I don't want to inherit that exception..
 
i mean for example in a datagrid tow fields shouldn't be null...and if user
leave them he gets an exception..
but i want to know in that exception that which fields are left..with
helping exception not checking them manually..

Nicholas Paldino said:
perspolis,

Are you trying to say that you are making decisions in logic based on
exceptions? This is a bad idea to begin with. The idea of exceptions are
just that, exceptional cases. For example, if the logic is dependent on the
file existing, and you just open it, and get an exception, you shouldn't try
to determine whether or not the file existed from the exception. Rather,
you should check for the existence of the file first, and then try and open
it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


perspolis said:
but sometimes the exceptions type are the same with diffrent message..in
that situation how can i make a decision??
in
message news:eteI#[email protected]...
perspolis,

You shouldn't be depending on this, but rather, the type. The only
reason you should need the HRESULT is for types of COMException. All other
exceptions, the HRESULT isn't going to help much.

I would base these decisions on the type.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I need Hresult to determin kind of exception and show user the apptopriate
message......
in some situations the exception is the same but the message are
diffrent..i
need hresult to get the correct exeption
"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in
message perspolis,

You mean the HRESULT that it stores? I would not store that,
nor
can
I
think of a situation why you really need it. It doesn't uniquely
identify
the type of exception (there is a many to one relationship between the
HRESULT and the exception type).

What are you trying to do?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I need to know the Exception number when an exeption
arise..
but the exception number is protected ..how can i access this number
when
an
exeption arise.. and also I don't want to inherit that exception..
 
Back
Top