[Gambas-user] Custom error class

Jesus Guardon jguardon at ...2035...
Wed Dec 16 20:35:50 CET 2009


Hi all

Perhaps this is an stupid question, but I'm confused at this point:

I'm trying to implement a custom error message window with information
about an error raised within a CATCH clause, using the Error class from
Gambas. Here is the code I'm not able to get it working:

_The error form 'FError'_

PRIVATE $error AS String

PUBLIC SUB Form_Open()
    ME.Center
    txtError.Clear
    txtError.Text = $error
END

PUBLIC SUB showError(myError AS Error)
    $error &= "[Error]\n" & myError.Text
    $error &= "\n[Where]\n" & myError.Where
    $error &= "\n[Backtrace]\n" & myError.Backtrace
    ME.ShowModal
END

PUBLIC SUB btnOk_Click()
    IF chkReport THEN
    ' TODO report error to a remote db
    ENDIF
    ME.Close
END

_Calling in a sub after CATCH_

CATCH
    FEerror.showError(Error)

-----

First of all, it is not possible to write "Error" keyword between the
two parenthesis, being formatted into "ERROR", syntactically wrong.

If I enclose the 'Error' keyword between curly brackets, as in
FErrors.showError({Error}) , no syntax error is raised, but a Gambas
error saying "Type mismatch: wanted Error, got Class instead".

What am I doing wrong, or is it possible to use this class the way I'm
doing?

Help appreciated!

Regards,

Jesús




More information about the User mailing list