Re: wtf?



jason <iaesun@xxxxxxxxx> wrote:

<snip - useful stuff>

You said in the other article that the error had been resolved - ignore
what you don't need in this :)

> > How did the parameter value end up in your command in the first place?
>
> ah, let's see. that's where it gets complicated. the parameters get
> added through an xml serialization trick, so that modifying the
> parameters is a data change, and not a code compile change. the various
> classes involved are ... tricky, but would it suffice to say that if
> the type is Guid, which it is, we can be pretty darn sure the xml
> serializer is working? or do you want to see that code?

No, that seems okay. It's done in the same thread, I assume?

> > What exactly is the situation here? What does the architecture look
> > like?
>
> basically there are several applications consuming a class library. the
> applications are highly varied, including ASP classic, ASP.NET, console
> applications, etc.

But how are they hooked together?

> the code i am showing you is in one method (the Login method) of one
> object (the User object). i don't have access to every consumer app,
> but what i can say with certainty is that this method works fine when
> called by the ASP classic app, but is producing the aforementioned
> error when called by the ASP.NET app. spitting out the values of the
> parameters has shown there is no difference in the data they are
> passing to the method call.

I don't understand quite how you're calling the method from an ASP
classic app - is this library being exposed through COM or something?

> > If you absolutely *have* to do exception to error code translation, I'd
> > strongly recommend doing it at a wrapper layer which does *nothing*
> > other than error translation.
>
> well i can't honestly say if we *have* to do exception to error code
> translation. it just seemed the easiest way to manage certain errors.

It may be in some situations, but in that case having it done in a
single wrapper layer would be better than peppering it around your
business logic.

> a classic example is when a user object insert fails because the the
> alternate key value provided already exists in the database. the
> exception that comes from the command's execute method doesn't seem to
> have any kind of error code. nor is the type so specific as to tell us
> exactly what happened, it's just an "SqlException" with a message that
> tells you what went wrong. that's not terribly useful, because
> different SqlExceptions mean very different things. and while most of
> the time we might be content saying "SqlException", in this case, we
> want to tell the user "hey, try another [key value]."

That sounds like you could translate the exception into a different
(business-specific) exception - that's still a lot better than error
codes.

> for that, the immediately accessible solution was to put in the stored
> procedure a test to see if the value exists, and if so return a certain
> code in an output parameter. then in the code, test the value of the
> output parameter, and process the specific error when it matters.
>
> i'm of course quite happy to learn a better solution to this type of
> condition, if you have such to offer :) it's just what we threw
> together with our best information in the trenches.
>
> thanks again for the discourse, and any suggestions.

Basically, using error codes is very error-prone in my experience - it
can be a pain to propagate them out (you're using "goto" here where if
you were using exceptions you could just throw one), and more
importantly, it can be all too easy to just not check them in the app
which uses the method.

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



Relevant Pages

  • Re: Application xxx has encountered a serious error and must shut
    ... Chris Tacke, Embedded MVP ... use of Queueacross multiple threads - and even my exception ... stopped my Serial port thread - last time it stopped the whole app:-O. ... NB I replaced the MS SerialPort with OpenNetCF Serial and this seems ...
    (microsoft.public.windowsce.app.development)
  • Re: Exception management question...
    ... There is code in my app that follows this general pattern: ... This allows an exception to be thrown with the next line of code attempts to ... >> to propagate up to a global exception handler which logs the exception ... > has determined that the app should terminate the UE handler has no means ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SqlceException.SqlceException
    ... First of all, i found the cause of the exception and corrected it, it was ... > same challenge in terms of deploying the initial SQL CE database. ... > db along with your app. ... it is the first time i am doing mobile applications and the first ...
    (microsoft.public.sqlserver.ce)
  • Re: strong key problems
    ... it is not clear what you are actually trying to accomplish by somehow ... i - how to create a strong key and use it in your applications. ... iv - any referencer to any app with strong name must also have a strong ... Unhandled Exception: System.Security.SecurityException: That assembly ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SqlException deserialization
    ... InitialCatalog are invalid so a login exception is thrown. ... The stacktrace before serialisation is: ... > without deserialization). ... >> soapformatter and then deserialize and the resulting SqlException has ...
    (microsoft.public.dotnet.framework.adonet)

Loading