[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TestError


It is what I understand and try to explain in my previous email!

thank you again👍️

Le mardi 11 novembre 2025 à 09:05 +0000, Bruce Steers a écrit :
> I have just modified the wiki Error pages to better explain how Error.Text
> always gives the "last" error message but like all other Error.class
> properties does not get reset so they should not be tested to see if an error
> occurred. only the Boolean Error is for that.
> (it will be visible tomorrow if you are not logged in)
> 
> Nb. The Boolean Error and Error.class are quite different things, meaning if
> Error is False it does not mean all the Error.class properties are null.
> 
> Hope it all makes sense now :)
> BruceS
> 
> 
> On Tue, 11 Nov 2025 at 06:51, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
> > Do you mean Error flag or Error.Text ?
> > Error should be false.
> > Try the following to test for a valid error.
> > 
> > If Error Then Print Error.Text
> > 
> > Error.Text may be filled but "Error" itself should be false after Return.
> > Do not test Error members like Error.Text or Error.Value just test Error
> > 
> > Can you confirm that Error itself is not False like you say.
> > 
> > 
> > BruceS
> > 
> > 
> > 
> > On Tue, 11 Nov 2025, 06:25 CD, <dessere.claude@xxxxxx> wrote:
> > > Thank you for your reply.
> > > 
> > > So, after rereading the documentation on error handling,
> > > 
> > > I found the following at https://gambaswiki.org/wiki/lang/error:
> > > 
> > > "The error flag is reset to FALSE when:
> > > 
> > > The RETURN instruction is executed.
> > > 
> > > A TRY instruction has been executed without any error."
> > > 
> > > Therefore, if I understand correctly, in the procedure:
> > > 
> > > Public Sub _GetRowHeight(iRow As Integer) As Integer
> > > 
> > > Try Return $cHeight[iRow]
> > > 
> > > Return _GetDefaultRowHeight()
> > > 
> > > End
> > > 
> > > the line `Try Return $cHeight[iRow]` generates an error,
> > > but the line `Return _GetDefaultRowHeight()` does not reset the error flag
> > > to false!
> > > 
> > > This doesn't match the documentation!
> > > 
> > > Personally, I will no longer test members of the `Error` class in the code
> > > without first using `Try`. 
> > > But I'm still not entirely sure how error handling works in Gambas.
> > > Perhaps more examples and explanations would be helpful.
> > > 
> > > 
> > > Le lundi 10 novembre 2025 à 18:28 +0000, Bruce Steers a écrit :
> > > > That is not how you check for errors.
> > > > It should be done like this after a Try...
> > > > 
> > > > If Error then
> > > >   Print Error.Text
> > > > Endif
> > > > 
> > > > After that Error.Text is not reset to null, it will always display the
> > > > last error text.
> > > > 
> > > > So randomly checking Error.Text or Error.Value at some time in your code
> > > > will just show the last error msg/value.
> > > > 
> > > > An Error is not something that always throws an exception.
> > > > 
> > > > Eg..
> > > > Try File.Load(sPath)
> > > > If Error Then
> > > >   Print Error.Text
> > > > Endif
> > > > 
> > > > Error text is filled in but there was no exception to halt the program.
> > > > 
> > > > So the only error in your form is how you are using Error.class
> > > > The error you are displaying is from this code in _GridView_Rows.class
> > > >
> > https://gitlab.com/gambas/gambas/-/blob/master/comp/src/gb.gui.base/.src/GridView/_GridView_Rows.class?ref_type=heads
> > > > Public Sub _GetRowHeight(iRow As Integer) As Integer
> > > > 
> > > > Try Return $cHeight[iRow]
> > > > Return _GetDefaultRowHeight()
> > > > 
> > > > End
> > > > 
> > > > It attempts 
> > > > Try Return $cHeight[iRow]
> > > > if that fails it returns _GetDefaultRowHeight()
> > > > 
> > > > Respects
> > > > BruceS
> > > > 
> > > > 
> > > > On Mon, 10 Nov 2025 at 15:47, CD <dessere.claude@xxxxxx> wrote:
> > > > > Hello,
> > > > > 
> > > > > I have an application with a main form
> > > > > from which I launch another form in ShowModal mode.
> > > > > 
> > > > > After this form is submitted, I test the Error class which returns:
> > > > > 
> > > > > Print Error.Class -> (Class 0x590273648788)
> > > > > Print Error.Code -> 6
> > > > > Print Error.Text -> Type mismatch: wanted Integer, got Null instead
> > > > > Print Error.Where -> [gb.gui.base]._GridView_Rows._GetRowHeight.161
> > > > > 
> > > > > I reproduced the issue with a Test application .
> > > > > 
> > > > > What about the error coming from
> > > > > [gb.gui.base]._GridView_Rows._GetRowHeight.161 ?
> > > > > 
> > > > > Project attached
> > > > > 
> > > > > Regards
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > [System]
> > > > > Gambas=3.21.0 7f84523 (master)
> > > > > OperatingSystem=Linux
> > > > > Distribution=Ubuntu 24.04.3 LTS (Noble Numbat)
> > > > > Kernel=6.8.0-86-generic
> > > > > Architecture=x86_64
> > > > > Cores=8
> > > > > Memory=7817M
> > > > > Language=fr_FR.UTF-8
> > > > > Platform=x11
> > > > > Desktop=MATE
> > > > > DesktopResolution=96
> > > > > DesktopScale=9
> > > > > WidgetTheme=blackmate
> > > > > Font=Ubuntu Mono,13
> > > > > DarkTheme=True
> > > > > [Programs]
> > > > > dpkg=Programme « dpkg » de gestion de paquets Debian version 1.22.6
> > > > > (amd64).
> > > > > gcc=gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
> > > > > git=git version 2.43.0
> > > > > msgmerge=msgmerge (GNU gettext-tools) 0.21
> > > > > rpmbuild=RPM version 4.18.2
> > > > > [Libraries]
> > > > > Cairo=libcairo.so.2.11800.0
> > > > > Curl=libcurl.so.4.8.0
> > > > > DBus=libdbus-1.so.3.32.4
> > > > > GDK2=libgdk-x11-2.0.so.0.2400.33
> > > > > GDK3=libgdk-3.so.0.2409.32
> > > > > GStreamer=libgstreamer-1.0.so.0.2402.0
> > > > > GTK+2=libgtk-x11-2.0.so.0.2400.33
> > > > > GTK+3=libgtk-3.so.0.2409.32
> > > > > OpenGL=libGL.so.1.7.0
> > > > > Poppler=libpoppler.so.134.0.0
> > > > > Poppler=libpoppler.so.73.0.0
> > > > > QT5=libQt5Core.so.5.15.13
> > > > > QT6=libQt6Core.so.6.4.2
> > > > > RSvg=librsvg-2.so.2.50.0
> > > > > SDL=libSDL2-2.0.so.0.3000.0
> > > > > SQLite3=libsqlite3.so.0.8.6
> > > > > [Environment]
> > > > > COMPIZ_CONFIG_PROFILE=mate
> > > > > DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
> > > > > DEBUGINFOD_URLS=https://debuginfod.ubuntu.com
> > > > > DEFAULTS_PATH=/usr/share/gconf/mate.default.path
> > > > > DESKTOP_SESSION=mate
> > > > > DISPLAY=:0
> > > > > GB_GUI=gb.gtk3
> > > > > GDMSESSION=mate
> > > > > GDM_LANG=fr_FR
> > > > > GIO_LAUNCHED_DESKTOP_FILE=<home>/Bureau/gambas3.desktop
> > > > > GIO_LAUNCHED_DESKTOP_FILE_PID=183671
> > > > > GNOME_KEYRING_CONTROL=/run/user/1000/keyring
> > > > > GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
> > > > > GTK3_MODULES=xapp-gtk3-module
> > > > > GTK_MODULES=appmenu-gtk-module:gail:atk-bridge:canberra-gtk-module
> > > > > GTK_OVERLAY_SCROLLING=0
> > > > > HOME=<home>
> > > > > INSIDE_CAJA_PYTHON=
> > > > > LANG=fr_FR.UTF-8
> > > > > LANGUAGE=fr_FR.UTF-8
> > > > > LC_ADDRESS=fr_FR.UTF-8
> > > > > LC_IDENTIFICATION=fr_FR.UTF-8
> > > > > LC_MEASUREMENT=fr_FR.UTF-8
> > > > > LC_MONETARY=fr_FR.UTF-8
> > > > > LC_NAME=fr_FR.UTF-8
> > > > > LC_NUMERIC=fr_FR.UTF-8
> > > > > LC_PAPER=fr_FR.UTF-8
> > > > > LC_TELEPHONE=fr_FR.UTF-8
> > > > > LC_TIME=fr_FR.UTF-8
> > > > > LOGNAME=<user>
> > > > > MANDATORY_PATH=/usr/share/gconf/mate.mandatory.path
> > > > > MATE_DESKTOP_SESSION_ID=this-is-deprecated
> > > > > PAPERSIZE=a4
> > > > > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr
> > > > > /games:/usr/local/games:/snap/bin
> > > > > PWD=<home>
> > > > > QT_ACCESSIBILITY=1
> > > > > QT_FONT_DPI=96
> > > > > QT_LOGGING_RULES=*.debug=false
> > > > > QT_QPA_PLATFORMTHEME=gtk2
> > > > > QT_SCALE_FACTOR=1
> > > > > SESSION_MANAGER=local/<hostname>:@/tmp/.ICE-
> > > > > unix/2550,unix/<hostname>:/tmp/.ICE-unix/2550
> > > > > SHELL=/bin/bash
> > > > > SHLVL=0
> > > > > SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
> > > > > TZ=:/etc/localtime
> > > > > UBUNTU_MENUPROXY=1
> > > > > USER=<user>
> > > > > XAUTHORITY=<home>/.Xauthority
> > > > > XDG_CONFIG_DIRS=/etc/xdg/xdg-mate:/etc/xdg
> > > > > XDG_CURRENT_DESKTOP=MATE
> > > > > XDG_DATA_DIRS=/usr/share/mate:/usr/share/mate:/usr/share/gnome:/usr/lo
> > > > > cal/share:/usr/share:/var/lib/snapd/desktop
> > > > > XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/<user>
> > > > > XDG_RUNTIME_DIR=/run/user/1000
> > > > > XDG_SEAT=seat0
> > > > > XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
> > > > > XDG_SESSION_CLASS=user
> > > > > XDG_SESSION_DESKTOP=mate
> > > > > XDG_SESSION_ID=c1
> > > > > XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
> > > > > XDG_SESSION_TYPE=x11
> > > > > XDG_VTNR=7
> > > > > 
> > > 
> > > 


References:
TestErrorCD <dessere.claude@xxxxxx>
Re: TestErrorBruce Steers <bsteers4@xxxxxxxxx>
Re: TestErrorCD <dessere.claude@xxxxxx>
Re: TestErrorBruce Steers <bsteers4@xxxxxxxxx>
Re: TestErrorBruce Steers <bsteers4@xxxxxxxxx>