Under disk basic I hook the DOS1 kernel style errorhandlers. I use the address F323 and F1e6 to catch, for example, disk offline errors. The errors are redirected to a custom handler. This works fine.
http://map.grauw.nl/articles/dos-error-handling.php
A unsuccessful file create wasn't intercepted. It took me quite a while to figure out why a file create was unsuccessful. The directory was full... A disassembly of 16h, helps to understand the problem.
ld de, FCB
ld c, CREATE
call BDOS ; BDOS EQU 0f37dh ( Basic Disk OS)
or a ; 000h if successful
jp nz, @Error ; 0ffh if unsuccessful
; Subroutine BDOS 16 (create file)
A461D: push de
T461E: call A440E ; validate FCB drive and filename
jr c,A464D ; invalid, quit with error
inc hl
inc hl
ld (hl),0 ; clear S2 byte
ld hl,YF2B9
ld a,"?"
ld bc,11
cpir ; wildcard char in filename ?
jr z,A464D ; yep, quit with error
call A42B5 ; find first directoryentry
jr nc,A4651 ; found, special actions for existing file/device
ld a,(YF2FE)
cp 0FFH ; found free direntry ?
jr z,A464D ; nope, quit with error (directory is full)
call A4317 ; get direntry
push hl
pop iy
jr A4669 ; setup direntry
A464D: pop de
ld a,0FFH
ret
Address F2FE, first free direntry (0FFH if none found)
Address F2B8, current direntry number
What is the best way to intercept these kinds of errors? I could check F2FE. Are there any other options?