Sure it is the responsibility of the client.
Logging details of other systems' internal errors is the
responsibility of the client? Why? What will be done with that
information's detail once logged.
The client should not assume that the server does not.
????
The client should not assume what the server does.
Correct, the client shouldn't assume anything about the service beyond
the published interface.
Exactly. Which is why more details are needed.
Which is probably one of the reasons it is considered best
practice to use SOAP faults with more details instead
of just HTTP status codes.
No matter how the error is passed, there still is no answer to the
question of 'how long is temporarily?'
The OP was questioning the use exceptions in general. You're are the
one who wants to include internal implementation details with the
exception. This is where we disagree.
It is more unambiguous but tend to be more magic numbers.
It is standard to use "text error codes".
How will the server know? Especially if the server's state is what you
call "a big mess".
If a service is unavailable at a time where it should be, then
retrying every 100 ms is not a good strategy, because there
is a pretty good chance that it will take minutes maybe hours.
Who is advocating continuous retries every 100 ms? How will the server
know if it will take minutes or hours to correct the issue? A poorly
behaved client could retry every 10ms regardless.
There is also a chance the service could be restored in seconds or
even milliseconds. Murphy behaves as he wishes.
True.
But then the service should not be unavailable in the first place.
Well then this whole discussion is moot because not only should the
service never be unavailable, the service should never encounter an
error condition. Oh to live in such a perfect world!
Absolutely true.
But no one suggested throwing SqlException.
Correct but you suggested that exceptions need to specifically
describe the internal error. Some examples you gave were
- quote -
no available connection in connection pool ...
transaction lock timeout ...
server not available ...
table does not exist...
- end quote -
Whether the thrown exceptions are SQL types or not is irrelevant to
the discussion. That is just the wrapper to the content you feel
should be available to the client. I don't believe the content should
describe specific implementation details unless requirements
specifically dictate that information should be made available.
The exceptions thrown externally should be implementation
independent.
This is what I don't understand. How can the exception be
implementation independent and yet describe internal implementation
errors in detail such as the ones quoted above? Please remember the
client's next action is to be based upon the specifics of the
implementation error.
- quote -
Otherwise the client code would have a hard time figuring out what to
do.
- end quote -
You're making a most general assumption that the client can follow a
specific path based upon the specific details of an error. I believe
that generally the only thing a client can do is try again later.
BTW, even the original post in this thread was, so no
problem here.
True, but exception information does not need to be dependent
on implementation.
Catching implementation specific exceptions and throwing API
defined exceptions is very standard.
Yes, this was mentioned several posts ago.
- quote -
Success or failure is pretty specific. More detail could be provided
by returning exception messages or a plethora of hresult-like values
but is such detail really necessary? In some cases yes but those
occasions are most generally when both client and service are
proprietary designs with built-in dependencies.
- end quote -
DI/IoC does not seem particular relevant for web services.
The concepts of avoiding undesirable dependencies are relevant. It
doesn't matter if those dependencies are between client and specific
service implementation or a service's published interface and a
specific implementation.
The SOAP standard defines so called server SOAP faults to
communicate this type of information.
And .NET framework both .asmx and WCF has added classes
to support it.
Either somebody is using it or a lot of resources has been wasted.
SOAP exceptions are nothing new and are useful when they are useful. I
first did that a decade ago to describe errors from an n-tier system a
web service fronted. There were twenty-odd custom faults but none
provided detailed information about specific implementation errors.
It's not about using these tools but how they are used. If using
custom SOAP faults provides no benefit to the client, what is the
point of using custom SOAP faults?
The discussion has devolved to discussing different ways to pass error
information. That makes it a good time to end this discussion. We have
been speaking in abstract generalities which contributes to our
disagreement. Using SOAP faults to describe internal implementation
errors in detail can be done but that does not mean it should always
be done. One size fits all really fits no one very well. In all
likelihood if we were discussing a more specific scenario with known
details we would be in closer agreement.
regards
A.G.