xHarbour Reference Documentation > Function Reference |
Sets or retrieves the last DOS error code.
DosError( [<nNewErrorCode>] ) --> nOsErrorCode
The function returns the last DOS error code as a numeric value.
The DosError() function returns an error code of the Disk Operating System (DOS) that is set when a disk, directory or file operation fails. This leads normally to a runtime error, so that DosError() is usually called within error handling routines to test if a DOS error has occured. DosError() retains its value until a new DOS error occurs, or a new return value is defined explicitely with <nNewErrorCode>. The return value of DosError() is set to zero after each successful DOS operation. The following table gives an overview of some DOS error codes together with their meaning.
Disk Operating System (DOS) error codes
Error | Description |
---|---|
1 | Invalid function number |
2 | File not found |
3 | Path not found |
4 | Too many open files (no handles left) |
5 | Access denied |
6 | Invalid handle |
7 | Memory control blocks destroyed |
8 | Insufficient memory |
9 | Invalid memory block address |
10 | Invalid environment |
11 | Invalid format |
12 | Invalid access code |
13 | Invalid data |
15 | Invalid drive was specified |
16 | Attempt to remove the current directory |
17 | Not same device |
18 | No more files |
19 | Attempt to write on write-protected media |
20 | Unknown unit |
21 | Drive not ready |
22 | Unknown command |
23 | Cyclic redundancy check (CRC) -- part of diskette is bad |
24 | Bad request structure length |
25 | Seek error |
26 | Unknown media type |
27 | Sector not found |
28 | Printer out of paper |
29 | Write fault |
30 | Read fault |
31 | General failure |
32 | Sharing violation |
33 | Lock violation |
34 | Invalid disk change |
35 | FCB unavailable |
36 | Sharing buffer overflow |
38 | Unable to complete the operation |
50 | Network request not supported |
51 | Remote computer not listening |
52 | Duplicate name on network |
53 | Network path not found |
54 | Network busy |
55 | Network device no longer exists |
56 | NETBIOS command limit exceeded |
57 | System error, NETBIOS error |
58 | Incorrect response from network |
59 | Unexpected network error |
60 | Incompatible remote adapter |
61 | Print queue full |
62 | Not enough space for print file |
63 | Print file was cancelled |
64 | Network name was denied |
65 | Access denied |
66 | Network device type incorrect |
67 | Network name not found |
68 | Network name limit exceeded |
69 | NETBIOS session limit exceeded |
70 | Sharing temporarily paused |
71 | Network request not accepted |
72 | Print or disk redirection is paused |
80 | File exists |
82 | Cannot make directory entry |
83 | Fail on INT 24 |
84 | Too many redirections |
85 | Duplicate redirection |
86 | Invalid password |
87 | Invalid parameter |
88 | Network data fault |
89 | Function not supported by network |
90 | Required system component not installed |
See also: | BEGIN SEQUENCE, ErrorBlock(), FError(), HB_OsError(), TRY...CATCH |
Category: | Error functions |
Source: | vm\errorapi.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows how to catch a "file not found" error // using DosError() within a TRY...CATCH error handling structure. PROCEDURE Main LOCAL oError DosError(55) // sets current DOS error code TRY ? DosError() // result: 55 USE xyz NEW // create DOS error CATCH oError IF DosError() == 2 ? "File not found:", oError:fileName QUIT ENDIF END RETURN
http://www.xHarbour.com