Re: Exception vs Boolean



Hold on John, you can't have it both ways....

Below, you say that an enum or boolean to indicate success or failure *is* a
"return code", but then you say that "Something returning the number of rows
updated is *not* the same as an error code."

When a command object's executeNonQuery method returns zero, isn't that
*possibly* an indication of an error processing the INSERT, UPDATE or
DELETE?

When a DataReader.Read returns False, *couldn't* that be an indication of an
error?

The answer to both of these is absolutely, yes.



"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1f4b1d578231593298d3d4@xxxxxxxxxxxxxxxxxxxxxxx
Cor Ligthert [MVP] <notmyfirstname@xxxxxxxxx> wrote:
By the way, if Scott wrote this somewhere,

Do not return error codes. Exceptions are the primary means of reporting
errors in frameworks."

No, he didn't.

Than do I agree with that in the context of his first message as well. I
was
only talking about Booleans and Enums, in general do I agree with the
text
above if it cannot be done in a simple way with returning the first two
types used in my message. I never would advice to use any return code.

What? An enum or boolean to indicate success or failure *is* a "return
code".

And to show that this can be even different, just have a look at the
DataAdapter Update where the returned integer can be used to see if all
the
rows are completely updated as it should be, this beside the exceptions
also
in this method (which can be set to ignore in the same method).

Something returning the number of rows updated is *not* the same as an
error code.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


.



Relevant Pages

  • Re: return value conventions in c
    ... >> When using int return values in C, is there a convention for ... boolean be named so that a non-zero value implies that the condition ... if I want to return multiple failure codes (and a single success ...
    (comp.programming)
  • Re: [5/6] 2.6.21-rc2: known regressions
    ... This is just a coding style thing, but I thought I should really point it ... on failure", or does it return "zero on success, negative on failure"? ... "negative error values" should preferably always be tested as such ... I've not generally been a huge fan of "boolean", ...
    (Linux-Kernel)
  • Re: Boolean operations on Enumerations
    ... I understand for the testing the enumeration state as in; ... Do you know the reasoning behind the boolean expression semantics? ... enum types for a state machine design as in; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boolean operations on Enumerations
    ... Enum m_state; ... Assignment expressions require a type that is the same, ... Do you know the reasoning behind the boolean expression semantics? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Complaint about return code convention in queue_work() etc.
    ... return false for failure, ... the function should return a "succeeded" boolean. ... queue_workand friends flagrantly violate this convention. ...
    (Linux-Kernel)