lhmouse/asteria

[RFC] Exceptions or error codes?

lhmouse opened this issue · 0 comments

Prolog: We don't take std::bad_alloc etc. into account here.

  1. std.filesystem.get_information() a.k.a. stat()
    Suggested solution: Return null on failure. Never throw exceptions.
    Rationale: Security consideration.
  2. std.filesystem.move_from() a.k.a. rename()
    Suggested solution: Always throw an exception on failure.
  3. std.filesystem.remove_recursive()
    Suggested solution: Return 0 if the path does not exist. Throw an exception otherwise.
  4. std.filesystem.directory_list()
    Suggested solution: Return null if the path does not exist. Throw an exception otherwise.
  5. std.filesystem.directory_create() a.k.a. mkdir()
    Suggested solution: Return false if a directory already exists. Throw an exception otherwise.
  6. std.filesystem.directory_remove() a.k.a. rmdir()
    Suggested solution: Return false if the path does not exist. Throw an exception otherwise.
  7. std.filesystem.file_read() a.k.a. read() and pread()
    Suggested solution: Return null if the path does not exist. Return an empty string if the end-of-file has been reached. Throw an exception otherwise.
  8. std.filesystem.file_stream() a.k.a. read() and pread()
    Suggested solution: Return null if the path does not exist. Return 0 if the end-of-file has been reached. Throw an exception otherwise.
  9. std.filesystem.file_write() a.k.a. write() and pwrite()
    Suggested solution: Always throw an exception on failure.
  10. std.filesystem.file_append() a.k.a. write() and pwrite()
    Suggested solution: Always throw an exception on failure.
  11. std.filesystem.copy_from()
    Suggested solution: Always throw an exception on failure.
  12. std.filesystem.file_remove()
    Suggested solution: Return false if the path does not exist. Throw an exception otherwise.