Announcement

Collapse
No announcement yet.

Throw message from .NET

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Throw message from .NET

    I run this class in .NET and it throws an error, construction is like:
    Code:
    try
    {
        // something goes wrong here..
    }
    catch (Exception Ex)
    {                
        // Close stuff or so here...
        // Ex.Message 
        throw Ex;
    }
    Ex.Message contains the correct error message like a specific database error$ (tested).
    The throw 'passes' it on but it gives a general message instead (ObjResult$)
    hellobasic

  • #2
    I know ADO offers an error interface, which you can call after OBJRESULT to get details. Great for getting the details when an SQL statement is bad (invalid table name, etc).

    Maybe whatever this "ex" is offers or can be made to offer some kind of "error detail" property???

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I know but that would be a work-around.

      ADO provides an error collection and is not passed via the exception.
      ADO.NET seems to pass the actual error message via the exception and that is nice.

      But in PB i guess there is no relationship between the error value and result.
      I suspect the objresult$ obtains a common error message from the Windows API.
      Iow, it does not use the message in this exception.
      Expectable.., it has no link to this exception type variable (assuming).

      If no good answer i'll do the work-around (sigh)
      hellobasic

      Comment


      • #4
        throw new Ex.message?

        Remarks
        The thrown exception is an object whose class is derived from System.Exception, for example:
        Code:
        class MyException : System.Exception {}
           throw new MyException();
        Usually the throw statement is used with try-catch or try-finally statements. When an exception is thrown, the program looks for the catch statement that handles this exception.
        ???
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          I'll check if the function throws a good exception message when the try catch is excluded.
          Then we'll see if it's able to pass the original text.
          hellobasic

          Comment


          • #6
            I removed the try/catch and the same error happens.
            So i don't think there is a relationship between the Exception object and the ERROR part in Windows.
            To bad, now i need a function to return the last error
            hellobasic

            Comment


            • #7
              Can't you add a GET-able property to the class containing the last error?

              ADO has that. When I got OBJERROR on an Execute, I could still GET this. (Discovery: it was one of the first things I needed to find because I had fat-fingered the tablename in a SELECT).

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                I just did

                Here is my PB code (not a property but a method)

                http://www.hellobasic.com/cgi-bin/fo...num=1220615658
                hellobasic

                Comment


                • #9
                  Property, method, whatever.

                  I do 'big ideas.' Details are left to staff.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment

                  Working...
                  X