RE: COM Exception handling

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: /dev/null (devnull_at_discussions.microsoft.com)
Date: 11/11/04


Date: Thu, 11 Nov 2004 07:28:15 -0800

My coworker found the simplest of solutions to this problem.

dim ex2 as System.Runtime.InteropServices.COMException
ex2 = ex.InnerException

I was then able to get access to the errorcode method

"/dev/null" wrote:

> I built a little asp.net form to let our users change their password, it's
> simple and works pretty well. I'd like to be able to treat exceptions
> properly but i am having trouble finding what's really going on.
>
> I am using this command to change the password :
> Entree.Invoke("ChangePassword", New Object() {OldPassword, NewPassword})
>
> This will trigger an exception when some situations are encountered. the
> exception name is the same whether the new password is not following the
> rules or if the old password is incorrect.
>
> Putting a breakpoint when an exception occurs, i can see using the "Autos"
> debug window that somewhere inside the Exception object, there is an error
> code. I can't figure out how to get to it using code... This error code
> isn't the same when the user enters an incorrect current password or does not
> repect the rules for new passwords.
>
> I get in the command window:
>
> ? ex.innerexception
> {System.Runtime.InteropServices.COMException}
> [System.Runtime.InteropServices.COMException]:
> {System.Runtime.InteropServices.COMException}
> HelpLink: Nothing
> InnerException: Nothing
> Message: "The specified network password is not correct."
> Source: ""
> StackTrace: Nothing
> TargetSite: Nothing
>
> In the "Autos" window i see that the 2nd line i get in the command window is
> expanded and shows the error code. How can i get access to what's inside
> "[System.Runtime.InteropServices.COMException]:
> {System.Runtime.InteropServices.COMException}"
>
> Thanks



Relevant Pages

  • Re: Structured exception information
    ... Doesn't feel as type-safe as advertised. ... What, _exactly_, will the handler do with the separate bits? ... Looking up the localized error message in the dictionary based on the *type-safe* error code that it got from the exception object, ... I'm looking forward to see a convincing solution for error code and the dictionary. ...
    (comp.lang.ada)
  • Re: Exception : an ugly grammer in programming
    ... machinism in programming languages. ... we return error code when we meet an error. ... But how about use exception in OOP? ... Exceptions originally were designed to handle unexpected conditions, ...
    (comp.lang.php)
  • Re: [PHP] Re: MySQL exceptions
    ... I don't think MySQL or even mysqli have any kind of exception throwing ... echo "Impossible connect to server."; ... completely before trying to use a dead connection. ... error code number would be encapsulated as an ...
    (php.general)
  • Exception : an ugly grammer in programming
    ... Yes, I'm doing PHP. ... machinism in programming languages. ... we return error code when we meet an error. ... But how about use exception in OOP? ...
    (comp.lang.php)
  • Re: Structured exception information
    ... A real example is a HTTP component that reports error code with value 404 and the GUI leyer that looks up the dictionary of messages for currently selected language to resolve it to whatever is appropriate for display. ... You can argue that return code instead of exception might do the job and that's true - but then we are back to the discussion of return codes vs. exceptions, which is a paradigm issue - which should be independent on the technical abilities of each solution. ...
    (comp.lang.ada)