fatal errors are not special

This commit is contained in:
Frédéric Mangano-Tarumi 2018-12-03 18:13:51 -05:00
parent 1d6ca8fc59
commit fcfb4a2a1d
2 changed files with 8 additions and 5 deletions

View File

@ -246,7 +246,7 @@ static ot::status process(ot::ogg_reader& reader, ot::ogg_writer* writer, const
return rc;
}
if (packet_count < 2)
return {ot::st::fatal_error, "Expected at least 2 Ogg packets"};
return {ot::st::error, "Expected at least 2 Ogg packets"};
return ot::st::ok;
}
@ -310,14 +310,14 @@ ot::status ot::run(const ot::options& opt)
rc = temporary_output.open(opt.path_out.c_str());
output = temporary_output.get();
} else {
rc = {ot::st::fatal_error,
rc = {ot::st::error,
"'" + opt.path_out + "' already exists. Use -y to overwrite."};
}
} else if (errno == ENOENT) {
rc = temporary_output.open(opt.path_out.c_str());
output = temporary_output.get();
} else {
rc = {ot::st::fatal_error,
rc = {ot::st::error,
"Could not identify '" + opt.path_in + "': " + strerror(errno)};
}
if (rc != ot::st::ok)

View File

@ -41,6 +41,9 @@ namespace ot {
* have it explictly mentionned in their documentation. By default, a non-ok status should be
* handled like an error.
*
* Error codes do not need to be ultra specific, and are mainly used to report special conditions to
* the caller function. Ultimately, only the error message in the #status is shown to the user.
*
* The cut error family means that the end of packet was reached when attempting to read the
* overflowing value. For example, cut_comment_count means that after reading the vendor string,
* less than 4 bytes were left in the packet.
@ -48,8 +51,9 @@ namespace ot {
enum class st {
/* Generic */
ok,
error,
standard_error, /**< Error raised by the C standard library. */
int_overflow,
standard_error,
/* Ogg */
end_of_stream,
end_of_page,
@ -65,7 +69,6 @@ enum class st {
cut_comment_data,
/* CLI */
bad_arguments,
fatal_error,
};
/**