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

Marc Guillaume alarch at alarch.pw
Thu Jun 9 22:55:17 CEST 2022


Le Thu, 9 Jun 2022 12:59:29 +0200,
Benoit Minisini <benoit.minisini at gambas-basic.org> a écrit :

> 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.

Is the fact that the mysql code numbers are not retrieved during an
error due to the same problem? 

It would be useful to have these codes to make decisions, some codes
being informative.



More information about the User mailing list