[Lazarus] Unknown error codes.

Carlos E. R. robin.listas at telefonica.net
Tue May 1 12:43:12 CEST 2018


On 2018-05-01 10:48, Rik van Kekem via Lazarus wrote:
> On 29-04-2018 23:55, Carlos E. R. via Lazarus wrote:
>> It does not list the error 26 I got.
>> It is possible that there are different numbers on different operating
>> systems? That list seems to be related to Windows, but the link does not
>> say.
>>
> It's always possible to get the text of an OS error via SysErrorMessage().

Ah!  I have been looking for such a function for hours. Yesterday I created my own functions to output text, getting the help from several help sources. Ok, Scrap those!


>
> Also note that the EInOutError codes in the range 0-99 represent OS
> error conditions, which are different for Windows and Linux. At least in
> Delphi they do.

Ok.

> 
> On Linux Showmessage(SysErrorMessage(26)) gives us:
> Text (code segment) file busy

Yes, it matches.


> On Windows it gives:
> The specified disk or diskette cannot be accessed.
> 
> Of course a program can generate an runtime error itself via Error(Code)
> in which case the code didn't come from the OS and it might mean
> something different.

Ah.

It maybe these: https://freepascal.org/docs-html/user/userap4.html

Yesterday I wrote my own Function RunTimeErrorString(I: Word): string; from that list.

begin
   case I of
       1: RunTimeErrorString:= 'Invalid function number';         //An invalid operating system call was attempted.
       2: RunTimeErrorString:= ' File not found';                 //Reported when trying to erase, rename or open a non-existent file.
       3: RunTimeErrorString:= ' Path not found';                 //Reported by the directory handling routines when a path does not exist or is invalid. Also reported when trying to access a non-existent file.
       4: RunTimeErrorString:= ' Too many open files';            //The maximum number of files currently opened by your process has been reached. Certain operating systems limit the number of files which can be opened concurrently, and this error can occur when this limit has been reached.
       5: RunTimeErrorString:= ' File access denied';             //Permission to access the file is denied. This error might be caused by one of several reasons:
...

(I can post it complete if it is of interest)


> Small test-program will give you a list:
> var
>   I: Integer;
> begin
>   for I := 0 to 99 do
>   begin
>     Memo1.Lines.Add(Format('%d - %s', [I, SysErrorMessage(I)]));
>   end;

:-)


> On Windows it gives:
> 0 - The operation completed successfully.
> 1 - Incorrect function.> 2 - The system cannot find the file specified.
> 3 - The system cannot find the path specified.
> 4 - The system cannot open the file.
> 5 - Access is denied.
...
> 99 -
> 
> On Linux it gives:
> 0 - Success
> 1 - Operation not permitted
> 2 - No such file or directory
> 3 - No such process
> 4 - Interrupted system call
> 5 - I/O error
...
> 99 - Cannot assign requested address
> 
> So, because of the differences in Windows and Linux it might be best to
> always show the SysErrorMessage(code) too (if it is indeed an OS error).
> It will generate a much clearer message.

Yes, indeed.

Thank you!


-- 
Cheers / Saludos,

		Carlos E. R.
		(from 42.3 x86_64 "Malachite" at Telcontar)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180501/63183945/attachment.sig>


More information about the Lazarus mailing list