More error data for copy and rename functions.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

More error data for copy and rename functions.

Post by Fangbeast »

It would be nice to be able to get more exact error information from Copy and Rename file functions.

At the moment, we have 0 if they fail, nonzero if they don't fail.

Would like some more depth to this if possible.

And maybe other file/filesystem commands as well please?

*EDIT* Never mind, GetLastError_ will do
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: More error data for copy and rename functions.

Post by HeX0R »

A native GetLastError() would be cool!
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: More error data for copy and rename functions.

Post by xorc1zt »

purebasic native last error would rely on GetLastError() anyway.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: More error data for copy and rename functions.

Post by Danilo »

xorc1zt wrote:purebasic native last error would rely on GetLastError() anyway.
It's meant to be cross platform, to get internal errors of PureBasic functions.
Most functions just return 0 on error, so you would call the PB error function
to get a code to know what happened.

Code: Select all

#PB_Error_File_NotFound             ; OpenDatabase, ReadFile, LoadFont, LoadImage, OpenLibrary, ...
#PB_Error_Disk_Full                 ; All file write functions (SaveImage, CreatePack, WritePreferenceXXX, WriteData, WriteLong, ...)
#PB_Error_File_NoAccess             ; all file functions, same than the two points above
#PB_Error_FileSystem_NoAccess       ; all file system functions (directory reading etc.)
#PB_Error_Disk_ReadOnly             ; all file write functions when used on a read-only device
#PB_Error_OutOfMemory               ; AllocateMemory, AddElement, CreateImage, CreateSprite, CreateMesh, AddMapElement, CopyArray, OpenWindow, ...
#PB_Error_Network_ConnectionTimeOut ; all network functions, SendMail etc..
#PB_Error_Network_NoConnection      ; all network functions, SendMail etc..
#PB_Error_Network_SendFailed        ; all network send functions
If AllocateMemory or AddElement fail, it is out of memory. But this can also happen with
other functions that allocate memory internally. CreateXXX, OpenXXX, ...

Why did LoadSprite fail? FileNotFound? OutOfMemory? UnsupportedImageFormat (InvalidData)? no access rights to that directory?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: More error data for copy and rename functions.

Post by c4s »

Danilo is right, this could be a useful feature.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply