runtime: status: add descriptive messages for status codes

This commit is contained in:
2026-05-31 17:34:12 +01:00
parent b9a3caf033
commit 187296ca62
2 changed files with 39 additions and 0 deletions
+1
View File
@@ -20,5 +20,6 @@ enum bshell_status {
}; };
extern enum bshell_status bshell_status_from_errno(int err); extern enum bshell_status bshell_status_from_errno(int err);
extern const char *bshell_status_get_description(int err);
#endif #endif
+38
View File
@@ -17,3 +17,41 @@ enum bshell_status bshell_status_from_errno(int err)
return BSHELL_ERR_INTERNAL_FAILURE; return BSHELL_ERR_INTERNAL_FAILURE;
} }
} }
const char *bshell_status_get_description(int err)
{
switch (err) {
case BSHELL_SUCCESS:
return "Success";
case BSHELL_ERR_EOF:
return "Unexpected end-of-file";
case BSHELL_ERR_BAD_SYNTAX:
return "Bad syntax";
case BSHELL_ERR_BAD_FORMAT:
return "Bad data format";
case BSHELL_ERR_BAD_STATE:
return "Object is in bad state";
case BSHELL_ERR_INVALID_VALUE:
return "Invalid value";
case BSHELL_ERR_INVALID_ARGUMENT:
return "Invalid argument";
case BSHELL_ERR_NO_MEMORY:
return "Out of memory";
case BSHELL_ERR_NO_ENTRY:
return "No such file or directory";
case BSHELL_ERR_NO_DATA:
return "No data available";
case BSHELL_ERR_NAME_EXISTS:
return "File or object already exists";
case BSHELL_ERR_NOT_SUPPORTED:
return "Operation not supported";
case BSHELL_ERR_IO_FAILURE:
return "I/O failure";
case BSHELL_ERR_ACCESS_DENIED:
return "Access denied";
case BSHELL_ERR_INTERNAL_FAILURE:
return "Internal failure";
default:
return "Unknown error";
}
}