[Gambas-user] Error.Raise an error with a code other than -1

Benoit Minisini benoit.minisini at gambas-basic.org
Thu Jun 9 12:59:29 CEST 2022


Le 09/06/2022 à 12:47, Bruce Steers a écrit :
> 
> Something like this would be handy Ben...
> https://gitlab.com/bsteers4/gambas/-/commit/14d5e172d50e75c8388acd85e36f730f0a049bfc 
> <https://gitlab.com/bsteers4/gambas/-/commit/14d5e172d50e75c8388acd85e36f730f0a049bfc>
> 
> There I simply added a new method to Error class.
> Error.RaiseCode(sMsg As String, iCode As Integer)
> 
> Works the same as Error.Raise(sMsg As String) but also sets a code other 
> than -1.
> 
> I was just playing with a bit of c
> 
> But in all seriousness the Error.Raise() method would be extra useful if 
> you can have an optional code parameter to set a value other than just 
> the -1 Error.Raise() gives at present.
> using a code could make for better handling in the Catch.
> 
> Unless it's already possible to set an error code?
> 
> Respects
> BruceS
> 
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

At the moment it's not really possible.

I have the project to create a true non-global error object so that we 
can do:

Catch <variable>

   Print <variable>.Text;; <variable>.Code
   ...

If I succeed, it will be possible to add some user property to this 
object (a tag for example), so that you can add your own information to 
the error.

Regards,

-- 
Benoît Minisini.


More information about the User mailing list