[C] Changed errors descriptions
This commit is contained in:
parent
d91c7ce9d1
commit
cd11dfd7de
12
lib/fort.c
12
lib/fort.c
@ -3618,18 +3618,18 @@ const char *ft_strerror(int error_code)
|
|||||||
{
|
{
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
case FT_MEMORY_ERROR:
|
case FT_MEMORY_ERROR:
|
||||||
return "Libfort error (out of memory)";
|
return "Out of memory";
|
||||||
case FT_GEN_ERROR:
|
case FT_GEN_ERROR:
|
||||||
return "Libfort error (general error)";
|
return "General error";
|
||||||
case FT_EINVAL:
|
case FT_EINVAL:
|
||||||
return "Libfort error (invalid argument)";
|
return "Invalid argument";
|
||||||
case FT_INTERN_ERROR:
|
case FT_INTERN_ERROR:
|
||||||
return "Libfort error (internal logic error)";
|
return "Internal libfort error";
|
||||||
default:
|
default:
|
||||||
if (error_code < 0)
|
if (error_code < 0)
|
||||||
return "Libfort unknown error";
|
return "Unknown error code";
|
||||||
else
|
else
|
||||||
return "Libfort success";
|
return "Success";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,11 +91,18 @@ SOFTWARE.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Libfort internal logic error.
|
* Libfort internal logic error.
|
||||||
|
*
|
||||||
|
* Usually such errors mean that something is wrong in
|
||||||
|
* libfort internal logic and in most of cases cause of
|
||||||
|
* these errors is a library bug.
|
||||||
*/
|
*/
|
||||||
#define FT_INTERN_ERROR -3
|
#define FT_INTERN_ERROR -3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General error.
|
* General error.
|
||||||
|
*
|
||||||
|
* Different errors that do not belong to the group of errors
|
||||||
|
* mentioned above.
|
||||||
*/
|
*/
|
||||||
#define FT_GEN_ERROR -4
|
#define FT_GEN_ERROR -4
|
||||||
|
|
||||||
|
@ -391,9 +391,8 @@ public:
|
|||||||
: property_owner_t(FT_ANY_ROW, FT_ANY_COLUMN, this),
|
: property_owner_t(FT_ANY_ROW, FT_ANY_COLUMN, this),
|
||||||
table_(ft_create_table())
|
table_(ft_create_table())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (table_ == NULL)
|
if (table_ == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -413,7 +412,7 @@ public:
|
|||||||
if (tbl.table_) {
|
if (tbl.table_) {
|
||||||
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
||||||
if (table_copy == NULL)
|
if (table_copy == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table copy");
|
||||||
|
|
||||||
stream_.str(std::string());
|
stream_.str(std::string());
|
||||||
if (tbl.stream_.tellp() >= 0) {
|
if (tbl.stream_.tellp() >= 0) {
|
||||||
@ -447,7 +446,7 @@ public:
|
|||||||
if (tbl.table_) {
|
if (tbl.table_) {
|
||||||
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
||||||
if (table_copy == NULL)
|
if (table_copy == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table copy");
|
||||||
|
|
||||||
stream_.str(std::string());
|
stream_.str(std::string());
|
||||||
if (tbl.stream_.tellp() >= 0) {
|
if (tbl.stream_.tellp() >= 0) {
|
||||||
@ -491,7 +490,7 @@ public:
|
|||||||
{
|
{
|
||||||
const char *str = c_str();
|
const char *str = c_str();
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table to string conversion");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,11 +91,18 @@ SOFTWARE.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Libfort internal logic error.
|
* Libfort internal logic error.
|
||||||
|
*
|
||||||
|
* Usually such errors mean that something is wrong in
|
||||||
|
* libfort internal logic and in most of cases cause of
|
||||||
|
* these errors is a library bug.
|
||||||
*/
|
*/
|
||||||
#define FT_INTERN_ERROR -3
|
#define FT_INTERN_ERROR -3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General error.
|
* General error.
|
||||||
|
*
|
||||||
|
* Different errors that do not belong to the group of errors
|
||||||
|
* mentioned above.
|
||||||
*/
|
*/
|
||||||
#define FT_GEN_ERROR -4
|
#define FT_GEN_ERROR -4
|
||||||
|
|
||||||
|
@ -391,9 +391,8 @@ public:
|
|||||||
: property_owner_t(FT_ANY_ROW, FT_ANY_COLUMN, this),
|
: property_owner_t(FT_ANY_ROW, FT_ANY_COLUMN, this),
|
||||||
table_(ft_create_table())
|
table_(ft_create_table())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (table_ == NULL)
|
if (table_ == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -413,7 +412,7 @@ public:
|
|||||||
if (tbl.table_) {
|
if (tbl.table_) {
|
||||||
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
||||||
if (table_copy == NULL)
|
if (table_copy == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table copy");
|
||||||
|
|
||||||
stream_.str(std::string());
|
stream_.str(std::string());
|
||||||
if (tbl.stream_.tellp() >= 0) {
|
if (tbl.stream_.tellp() >= 0) {
|
||||||
@ -447,7 +446,7 @@ public:
|
|||||||
if (tbl.table_) {
|
if (tbl.table_) {
|
||||||
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
ft_table_t *table_copy = ft_copy_table(tbl.table_);
|
||||||
if (table_copy == NULL)
|
if (table_copy == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table copy");
|
||||||
|
|
||||||
stream_.str(std::string());
|
stream_.str(std::string());
|
||||||
if (tbl.stream_.tellp() >= 0) {
|
if (tbl.stream_.tellp() >= 0) {
|
||||||
@ -491,7 +490,7 @@ public:
|
|||||||
{
|
{
|
||||||
const char *str = c_str();
|
const char *str = c_str();
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
throw std::runtime_error("Libfort runtime error");
|
throw std::runtime_error("Error during table to string conversion");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1022,18 +1022,18 @@ const char *ft_strerror(int error_code)
|
|||||||
{
|
{
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
case FT_MEMORY_ERROR:
|
case FT_MEMORY_ERROR:
|
||||||
return "Libfort error (out of memory)";
|
return "Out of memory";
|
||||||
case FT_GEN_ERROR:
|
case FT_GEN_ERROR:
|
||||||
return "Libfort error (general error)";
|
return "General error";
|
||||||
case FT_EINVAL:
|
case FT_EINVAL:
|
||||||
return "Libfort error (invalid argument)";
|
return "Invalid argument";
|
||||||
case FT_INTERN_ERROR:
|
case FT_INTERN_ERROR:
|
||||||
return "Libfort error (internal logic error)";
|
return "Internal libfort error";
|
||||||
default:
|
default:
|
||||||
if (error_code < 0)
|
if (error_code < 0)
|
||||||
return "Libfort unknown error";
|
return "Unknown error code";
|
||||||
else
|
else
|
||||||
return "Libfort success";
|
return "Success";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,23 +6,23 @@ void test_error_codes(void)
|
|||||||
{
|
{
|
||||||
// Nonnegative code is success
|
// Nonnegative code is success
|
||||||
{
|
{
|
||||||
assert_str_equal(ft_strerror(FT_SUCCESS), "Libfort success");
|
assert_str_equal(ft_strerror(FT_SUCCESS), "Success");
|
||||||
assert_str_equal(ft_strerror(0), "Libfort success");
|
assert_str_equal(ft_strerror(0), "Success");
|
||||||
assert_str_equal(ft_strerror(1), "Libfort success");
|
assert_str_equal(ft_strerror(1), "Success");
|
||||||
assert_str_equal(ft_strerror(2), "Libfort success");
|
assert_str_equal(ft_strerror(2), "Success");
|
||||||
assert_str_equal(ft_strerror(42), "Libfort success");
|
assert_str_equal(ft_strerror(42), "Success");
|
||||||
assert_str_equal(ft_strerror(INT_MAX), "Libfort success");
|
assert_str_equal(ft_strerror(INT_MAX), "Success");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error codes
|
// Error codes
|
||||||
{
|
{
|
||||||
assert_str_equal(ft_strerror(FT_MEMORY_ERROR), "Libfort error (out of memory)");
|
assert_str_equal(ft_strerror(FT_MEMORY_ERROR), "Out of memory");
|
||||||
assert_str_equal(ft_strerror(FT_EINVAL), "Libfort error (invalid argument)");
|
assert_str_equal(ft_strerror(FT_EINVAL), "Invalid argument");
|
||||||
assert_str_equal(ft_strerror(FT_INTERN_ERROR), "Libfort error (internal logic error)");
|
assert_str_equal(ft_strerror(FT_INTERN_ERROR), "Internal libfort error");
|
||||||
assert_str_equal(ft_strerror(FT_GEN_ERROR), "Libfort error (general error)");
|
assert_str_equal(ft_strerror(FT_GEN_ERROR), "General error");
|
||||||
|
|
||||||
assert_str_equal(ft_strerror(-42), "Libfort unknown error");
|
assert_str_equal(ft_strerror(-42), "Unknown error code");
|
||||||
assert_str_equal(ft_strerror(-666), "Libfort unknown error");
|
assert_str_equal(ft_strerror(-666), "Unknown error code");
|
||||||
assert_str_equal(ft_strerror(-INT_MAX), "Libfort unknown error");
|
assert_str_equal(ft_strerror(-INT_MAX), "Unknown error code");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user