mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-06 12:10:28 +02:00
(Conventions): Use `system-error-errno' instead of explicit code
This commit is contained in:
parent
019ac1c987
commit
daabbf15d7
1 changed files with 5 additions and 11 deletions
|
@ -68,15 +68,12 @@ the documentation.
|
|||
|
||||
For ways to deal with exceptions, @ref{Exceptions}.
|
||||
|
||||
Errors which the C-library would report by returning a NULL
|
||||
pointer or through some other means are reported by raising a
|
||||
@code{system-error} exception.
|
||||
The value of the Unix @code{errno} variable is available
|
||||
Errors which the C-library would report by returning a NULL pointer or
|
||||
through some other means are reported by raising a @code{system-error}
|
||||
exception. The value of the Unix @code{errno} variable is available
|
||||
in the data passed by the exception.
|
||||
|
||||
Here's an ad-hoc@footnote{This may be changed in the future; be prepared
|
||||
to rewrite this sort of code.} way to extract the @code{errno} value
|
||||
from an exception:
|
||||
It can be extracted with the function @code{system-error-errno}:
|
||||
|
||||
@example
|
||||
(catch
|
||||
|
@ -84,7 +81,7 @@ from an exception:
|
|||
(lambda ()
|
||||
(mkdir "/this-ought-to-fail-if-I'm-not-root"))
|
||||
(lambda stuff
|
||||
(let ((errno (car (list-ref stuff 4))))
|
||||
(let ((errno (system-error-errno 4)))
|
||||
(cond
|
||||
((= errno EACCES)
|
||||
(display "You're not allowed to do that."))
|
||||
|
@ -95,9 +92,6 @@ from an exception:
|
|||
(newline))))
|
||||
@end example
|
||||
|
||||
The important thing to note is that the @code{errno} value can be
|
||||
extracted with @code{(car (list-ref stuff 4))}.
|
||||
|
||||
@node Ports and File Descriptors
|
||||
@section Ports and File Descriptors
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue