errno
errno — detects and numbers errors.
errno ();
none
The system error number.
When a function fails it returns a value and optionally sets the system
error number. The errno function can be used to check
the current error number. To check error numbers against constant error code
in your program remember to include the file with:
require_lisp ("Errno.lsp");.
![]() | |
Calling the |
In this example, we first define a function to remove a file. Then we call that function on a non-existing file to generate an error. Finally, we check the returned error code to get the error message.
function remove_file(file)
{
unlink(file);
errno();
}
Gamma> ret_val = remove_file("/tmp/xyz");
2
Gamma> strerror(2);
"No such file or directory"
Gamma>