Merge pull request #51791 from mhilbrunner/better-error-names

Improve error descriptions
This commit is contained in:
Max Hilbrunner 2021-08-23 20:13:32 +02:00 committed by GitHub
commit 0df9895eb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 49 deletions

View file

@ -31,55 +31,55 @@
#include "error_list.h" #include "error_list.h"
const char *error_names[] = { const char *error_names[] = {
"No error", "OK", // OK
"Generic error", "Failed", // FAILED
"Requested operation is unsupported/unavailable", "Unavailable", // ERR_UNAVAILABLE
"The object hasn't been set up properly", "Unconfigured", // ERR_UNCONFIGURED
"Missing credentials for requested resource", "Unauthorized", // ERR_UNAUTHORIZED
"Parameter out of range", "Parameter out of range", // ERR_PARAMETER_RANGE_ERROR
"Out of memory", "Out of memory", // ERR_OUT_OF_MEMORY
"File not found", "File not found", // ERR_FILE_NOT_FOUND
"Bad drive", "File: Bad drive", // ERR_FILE_BAD_DRIVE
"Bad path", "File: Bad path", // ERR_FILE_BAD_PATH
"Permission denied", "File: Permission denied", // ERR_FILE_NO_PERMISSION
"Already in use", "File already in use", // ERR_FILE_ALREADY_IN_USE
"Can't open file", "Can't open file", // ERR_FILE_CANT_OPEN
"Can't write file", "Can't write file", // ERR_FILE_CANT_WRITE
"Can't read file", "Can't read file", // ERR_FILE_CANT_READ
"File unrecognized", "File unrecognized", // ERR_FILE_UNRECOGNIZED
"File corrupt", "File corrupt", // ERR_FILE_CORRUPT
"Missing dependencies for file", "Missing dependencies for file", // ERR_FILE_MISSING_DEPENDENCIES
"Unexpected eof", "End of file", // ERR_FILE_EOF
"Can't open resource/socket/file", // File too? What's the difference to ERR_FILE_CANT_OPEN "Can't open", // ERR_CANT_OPEN
"Can't create", // What can't be created, "Can't create", // ERR_CANT_CREATE
"Query failed", // What query, "Query failed", // ERR_QUERY_FAILED
"Already in use", "Already in use", // ERR_ALREADY_IN_USE
"Resource is locked", "Locked", // ERR_LOCKED
"Timeout", "Timeout", // ERR_TIMEOUT
"Can't connect", "Can't connect", // ERR_CANT_CONNECT
"Can't resolve hostname", // I guessed it's the hostname here. "Can't resolve", // ERR_CANT_RESOLVE
"Connection error", "Connection error", // ERR_CONNECTION_ERROR
"Can't acquire resource", "Can't acquire resource", // ERR_CANT_ACQUIRE_RESOURCE
"Can't fork", "Can't fork", // ERR_CANT_FORK
"Invalid data", "Invalid data", // ERR_INVALID_DATA
"Invalid parameter", "Invalid parameter", // ERR_INVALID_PARAMETER
"Item already exists", "Already exists", // ERR_ALREADY_EXISTS
"Item does not exist", "Does not exist", // ERR_DOES_NOT_EXIST
"Can't read from database", // Comments say, it's full? Is that correct? "Can't read database", // ERR_DATABASE_CANT_READ
"Can't write to database", // Is the database always full when this is raised? "Can't write database", // ERR_DATABASE_CANT_WRITE
"Compilation failed", "Compilation failed", // ERR_COMPILATION_FAILED
"Method not found", "Method not found", // ERR_METHOD_NOT_FOUND
"Link failed", "Link failed", // ERR_LINK_FAILED
"Script failed", "Script failed", // ERR_SCRIPT_FAILED
"Cyclic link detected", "Cyclic link detected", // ERR_CYCLIC_LINK
"Invalid declaration", "Invalid declaration", // ERR_INVALID_DECLARATION
"Duplicate symbol", "Duplicate symbol", // ERR_DUPLICATE_SYMBOL
"Parse error", "Parse error", // ERR_PARSE_ERROR
"Resource is busy", "Busy", // ERR_BUSY
"Skip error", // ???? What's this? String taken from the docs "Skip", // ERR_SKIP
"Help error", // More specific? "Help", // ERR_HELP
"Bug", "Bug", // ERR_BUG
"Printer on fire", "Printer on fire", // ERR_PRINTER_ON_FIRE
}; };
static_assert(sizeof(error_names) / sizeof(*error_names) == ERR_MAX); static_assert(sizeof(error_names) / sizeof(*error_names) == ERR_MAX);

View file

@ -36,6 +36,11 @@
* values can be more detailed in the future. * values can be more detailed in the future.
* *
* This is a generic error list, mainly for organizing a language of returning errors. * This is a generic error list, mainly for organizing a language of returning errors.
*
* Errors:
* - Are added to the Error enum in core/error/error_list.h
* - Have a description added to error_names in core/error/error_list.cpp
* - Are bound with BIND_CORE_ENUM_CONSTANT() in core/core_constants.cpp
*/ */
enum Error { enum Error {