Int 21H [3.0] Function 59H (89) Get extended error information

Obtains detailed error information after a previous unsuccessful Int 21H function call, including the recommended remedial action.

Call with:

AH = 59H

BX = 00H

Returns:

AX = extended error code

01H function number invalid

02H file not found

03H path not found

04H too many open files

05H access denied

06H handle invalid

07H memory control blocks destroyed

08H insufficient memory

09H memory block address invalid

0AH (10) environment invalid

0BH (11) format invalid

0CH (12) access code invalid

0DH (13) data invalid

0EH (14) unknown unit

0FH (15) disk drive invalid

10H (16) attempted to remove current directory

11H (17) not same device

12H (18) no more files

13H (19) disk write-protected

14H (20) unknown unit

15H (21) drive not ready

16H (22) unknown command

17H (23) data error (CRC)

18H (24) bad request structure length

19H (25) seek error

1AH (26) unknown media type

1BH (27) sector not found

1CH (28) printer out of paper

1DH (29) write fault

1EH (30) read fault

1FH (31) general failure

20H (32) sharing violation

21H (33) lock violation

22H (34) disk change invalid

23H (35) FCB unavailable

24H (36) sharing buffer exceeded

25H—31H reserved

32H (50) unsupported network request

33H (51) remote machine not listening

34H (52) duplicate name on network

35H (53) network name not found

36H (54) network busy

37H (55) device no longer exists on network

38H (56) netBIOS command limit exceeded

39H (57) error in network adapter hardware

3AH (58) incorrect response from network

3BH (59) unexpected network error

3CH (60) remote adapter incompatible

3DH (61) print queue full

3EH (62) not enough space for print file

3FH (63) print file canceled

40H (64) network name deleted

41H (65) network access denied

42H (66) incorrect network device type

43H (67) network name not found

44H (68) network name limit exceeded

45H (69) netBIOS session limit exceeded

46H (70) file sharing temporarily paused

47H (71) network request not accepted

48H (72) print or disk redirection paused

49H—4FH reserved

50H (80) file already exists

51H (81) reserved

52H (82) cannot make directory

53H (83) fail on Int 24H (critical error)

54H (84) too many redirections

55H (85) duplicate redirection

56H (86) invalid password

57H (87) invalid parameter

58H (88) network device fault

59H (89) function not supported by network

5AH (90) required system component not installed

BH = error class

01H if out of resource (such as storage or handles)

02H if not error, but temporary situation (such as

locked region in file) that can be expected to

end

03H if authorization problem

04H if internal error in system software

05H if hardware failure

06H if system software failure not the fault of the

active process (such as missing configuration

files)

07H if application program error

08H if file or item not found

09H if file or item of invalid type or format

0AH (10) if file or item locked

0BH (11) if wrong disk in drive, bad spot on disk, or

storage medium problem

0CH (12) if item already exists

0DH (13) unknown error

BL = recommended action

01H retry reasonable number of times, then prompt

user to select abort or ignore

02H retry reasonable number of times with delay

between retries, then prompt user to select

abort or ignore

03H get corrected information from user (typically

caused by incorrect filename or drive

specification)

04H abort application with cleanup (i.e., terminate

the program in as orderly a manner as possible:

releasing locks, closing files, etc.)

05H perform immediate exit without cleanup

06H ignore error

07H retry after user intervention to remove cause of

error

CH = error locus

01H unknown

02H block device (disk or disk emulator)

03H network

04H serial device

05H memory

and, for MS-DOS 3.0 and later,

ES:DI = ASCIIZ volume label of disk to insert, if AX = 0022H

(invalid disk change)

Notes:

This function may be called after any other Int 21H function call that returned an error status, in order to obtain more detailed information about the error type and the recommended action. If the previous Int 21H function call had no error, 0000H is returned in register AX. This function may also be called during the execution of a critical-error (Int 24H) handler.

The contents of registers CL, DX, SI, DI, BP, DS, and ES are destroyed by this function.

Note that extended error codes 13H—1FH (19—31) and 34 (22H) correspond exactly to the error codes 0—0CH (0—12) and 0FH (15) returned by Int 24H.

You should not code your programs to recognize only specific error numbers if you wish to ensure upward compatibility, because new error codes are added in each version of MS-DOS.

Example:

Attempt to open the file named NOSUCH.DAT using a file control block; if the open request fails, get the extended error code.

myfcb db 0 ; drive = default

db 'NOSUCH ' ; filename, 8 chars

db 'DAT' ; extension, 3 chars

db 25 dup (0) ; remainder of FCB

.

.

.

label1: ; open the file

mov ah,0fh ; function number

mov dx,seg myfcb ; address of FCB

mov ds,dx

mov dx,offset myfcb

int 21h ; transfer to MS-DOS

or al,al ; check open status

jz success ; jump if opened OK

; open failed, get

; extended error info

mov ah,59h ; function number

xor bx,bx ; BX must = 0

int 21h ; transfer to MS-DOS

or ax,ax ; double check for error

jz success ; jump if no error

cmp bl,2 ; should we retry?

jle label1 ; yes, jump

jmp error ; no, give up

.

.

.