Closed ranger-turtle closed 6 months ago
IscException
is internal
. And FbException
derives from DbException
where ErrorCode
is defined as int
anyway.
IscException
isinternal
. AndFbException
derives fromDbException
whereErrorCode
is defined asint
anyway.
Thank you for answer but end-programmers would use ErrorCode
from FbException
in catch (Exception) when (condition)
section anyway and it would be more pleasant to read if it would be at least compared to enum.
By the way, I guess I have a better idea - I would just make the enum itself, and leave ErrorType
unchanged in all classes, including FbException
. End-programmer can just cast the value to int
in comparisons. What do you think?
Thank you for answer but end-programmers would use ErrorCode from FbException in catch (Exception) when (condition) section anyway and it would be more pleasant to read if it would be at least compared to enum.
Sure. But you would have to change it in DbException
in the first place.
By the way, I guess I have a better idea - I would just make the enum itself, and leave ErrorType unchanged in all classes, including FbException. End-programmer can just cast the value to int in comparisons. What do you think?
I think the best solution would be to have something like FbErrorCodes
class with bunch of fields and allow simply to compare ErrorCode
to known field. That would give you the textual representation of error code as well as simplicity of using it. Something like catch (FbException ex) when (ex.ErrorCode == FbErrorCodes.FooBar)
.
I think the best solution would be to have something like FbErrorCodes class with bunch of fields and allow simply to compare ErrorCode to known field. That would give you the textual representation of error code as well as simplicity of using it. Something like catch (FbException ex) when (ex.ErrorCode == FbErrorCodes.FooBar).
Fairly good idea but instead of bunch of fields, I would give one field of enum type.
That would require explicit cast to enum.
I have noticed that ErrorCode property in IscException can be changed to enum to make referring to the constants more readable. However, I am not sure it is a good idea, since it may break systems depending on .NET Provider too much.
I am going to refer to this doc: https://www.firebirdsql.org/pdfrefdocs/Firebird-2.1-ErrorCodes.pdf