Error handling in Basic4PPC

Discussion in 'Questions (Windows Mobile)' started by TWELVE, May 1, 2008.

  1. TWELVE

    TWELVE Active Member Licensed User

    Hello,

    i want prevent users from getting error message boxes, that contain cryptic error messages or even such with no error description.Therefore i tried a bit with the B4P error handler.This is working, if it's been triggered i still do not know what the exact error was and therefore cannot take the appropriate measure to continue.All i then can assume is: in this sub an error has occured.

    Question: is there a chance to get the error description the error popup is presenting to the user..? if not, how do you handle errors in your code and how do you catch them..?

    In certain other dialects i used to use a structure like this:

    if function(arguments)
    ...
    do something that depends on function
    ...
    Else
    ...
    do some corrective code here
    MsgBox("file cannot be opened !")
    end if

    Why do B4P functions or routines not give back a return code of true or false..? Or do they..? My own created do and can be handled like outlined, by use of the Return directive.

    Any other ways or suggestion how to handle that effectively..?



    kind regards

    TWELVE
     
  2. Cableguy

    Cableguy Expert Licensed User

    Error handling in B4PPC is done using the Errorlabel method...
    Taken from the B4PPC Helper:

    Since the Error code or description seem to be "intalation" dependant, (it seems that we need to actually install the errorcode reference file....) there is not currently available way to trap specific errors, but we can do some fancy coding and cascade a series of errorlabels, to try to catch an error at a specific code line or block...
     
  3. agraham

    agraham Expert Licensed User

    This is a deliberarate design feature of the CLR. Errors are handled by throwing exceptions and catching them by error-handling code, similar to C++. Every B4PPC Sub actually has an exception handler, it is this which puts up the message box when an error occurs. Using Errorlabel replaces this default handler with your own code. Unfortunately, at the moment, there is no way to detect which exception has occurred.

    Recently I made a suggestion to Erel about this and he has agreed to put a facility in the next release of B4PPC which will provide low-level access to the exception details. In anticipation I have the library and help file/tutorial ready. :cool:
     
  4. mamuen

    mamuen Member Licensed User

    Hello TWELVE,

    There are no functions in Basic4ppc but instead every sub can return a value
    with the keyword "Return"

    Sub Mean (a,b)
    Return (a+b)/2
    End Sub

    Greatings mamuen
     
  5. yildi

    yildi Member Licensed User

    You are really amazing agraham! :sign0098:

    Murat
     
  6. TWELVE

    TWELVE Active Member Licensed User

    Yas, this guy is really invaluable for this community...

    cheers

    TWELVE
     
  7. agraham

    agraham Expert Licensed User

    :sign0100: Aw shucks guys - Shuffles feet embarrassedly. I do really only do this for the fun of it and to let other people have the benefit of my (too many :() years of exxperience
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    :sign0156:
     
  9. agraham

    agraham Expert Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice