Hi, David. The exn:fail:filesystem and exn:fail:network do provide the errno code, If you are only working in one OS, you can also rely on the errno code. If you are working on multiple OSes, it might be a problem since Racket have not yet provided an abstract layer on the errno code.
If you prefer to detect the error type via (exn-message), that would be fine for Racket, I do not think Racket will change the messages unless your OS change its standard c library. On Tue, Nov 29, 2016 at 1:18 PM, David Storrs <[email protected]> wrote: > After sending this I realized that I could define my own exception types > and use those. The original question, though, was how to get the built-in > exception hierarchy expanded into something more fine-grained. > > On Mon, Nov 28, 2016 at 7:46 PM, David Storrs <[email protected]> > wrote: > >> I'm doing some "write files to disk" work and noticing that the exception >> system for the filesystem isn't terribly fine-grained. Leaving aside >> exceptions that pertain to Racket's module system we only have: >> >> exn:fail:filesystem (something went wrong in general) >> and >> exn:fail:filesystem:exists? (you tried to create a file that already >> exists) >> >> If I'm, e.g. using rename-file-or-directory and it fails I need to parse >> the actual message string to know what went wrong: >> >> (define msg (exn-message e)) ;; assume we're in a handler >> (cond [(regexp-match #px"No such file or directory" msg) ...] >> [(regexp-match #px"the destination file already exists" msg) >> ...]) >> >> This is verbose, error-prone, and vulnerable to changes in the messages >> that could happen in future versions of Racket. >> >> I would prefer to have exception types that deal with this -- for example: >> >> exn:fail:filesystem:source-not-found >> exn:fail:filesystem:target-exists >> >> >> What would be involved in doing this? Should I be filing a feature >> request on Github? >> > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

