diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-05-01 06:32:34 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-05-01 06:32:34 -0700 |
commit | 488c1ba59416a0b2ce87a36d7df3026e334d66b9 (patch) | |
tree | f0e4f92351f5eb98c07206828cb80615a1a8fdce /lib.c | |
parent | c7888220b30e5933b76c0d5359c6f56874859fee (diff) | |
download | txr-488c1ba59416a0b2ce87a36d7df3026e334d66b9.tar.gz txr-488c1ba59416a0b2ce87a36d7df3026e334d66b9.tar.bz2 txr-488c1ba59416a0b2ce87a36d7df3026e334d66b9.zip |
lib: more nuanced file access errors.
Several new more specific exception types are derived from
file-error and used. Error handlers can distinguish unexpected
non-existence, unexpected existence and permission errors
from each other and other errors.
* lib.c (path_not_found_s, path_exists_s, path_permission_s):
New symbol variables.
(obj_init): New variables initialized.
* lib.h (path_not_found_s, path_exists_s, path_permission_s):
Declared.
* parser.c (open_txr_file): Use new errno_to_file_error
function to convert errno to exception symbol.
* socket.c (open_sockfd): Likewise.
* stream.c (open_directory, open_file, open_fileno,
open_command, open_process, run, remove_path, rename_path):
Likewise, and process-error is used in open_process and run
instead of file-error for problems related to creating the
process.
* sysif.c (errno_to_file_error): New function.
(mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, mknod_wrap,
chmod_wrap, symlink_wrap, link_wrap, readlink_wrap, stat_impl,
umask_wrap, ): Use
errno_to_file_error to convert errno to exception symbol.
(exec_wrap): Use process-error instead of file-error.
* sysif.c (errno_to_file_error): Declared.
* unwind.c (uw_init): Register path-not-found, path-exists and
path-permission as subtypes of file-error.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -108,6 +108,7 @@ val error_s, type_error_s, internal_error_s, panic_s; val numeric_error_s, range_error_s; val query_error_s, file_error_s, process_error_s, syntax_error_s; val timeout_error_s, system_error_s, alloc_error_s; +val path_not_found_s, path_exists_s, path_permission_s; val warning_s, defr_warning_s, restart_s, continue_s; val gensym_counter_s, nullify_s, from_list_s, lambda_set_s, length_s; val rplaca_s, rplacd_s, seq_iter_s; @@ -10844,6 +10845,9 @@ static void obj_init(void) system_error_s = intern(lit("system-error"), user_package); timeout_error_s = intern(lit("timeout-error"), user_package); alloc_error_s = intern(lit("alloc-error"), user_package); + path_not_found_s = intern(lit("path-not-found"), user_package); + path_exists_s = intern(lit("path-exists"), user_package); + path_permission_s = intern(lit("path-permission"), user_package); assert_s = intern(lit("assert"), user_package); warning_s = intern(lit("warning"), user_package); defr_warning_s = intern(lit("defr-warning"), user_package); |