1
0
forked from 0ad/0ad
0ad/source/lib/lib_errors.h
janwas 7e6d38314d allocators: fix OverrunProtector - avoid crash at exit if the object was never actually used
lib: add display_msgw which is a wrapper around the sys_display_msgw
impl and takes care of translating text
lib_errors: codes are now an enum (this will allow a special return type
and make documentation much more clear); codes are defined in the
header, not from lib.h
wsdl: resolve todo comment

This was SVN commit r3217.
2005-12-10 07:04:31 +00:00

96 lines
3.8 KiB
C

// notes:
// - file is called lib_errors.h because 0ad has another errors.cpp and
// the MS linker isn't smart enough to deal with object files
// of the same name but in different paths.
// - the first part of this file is a normal header; the second contains
// X macros and is only active if ERR is defined (i.e. someone is
// including this header for the purpose of using them).
#ifndef ERRORS_H__
#define ERRORS_H__
// limits on the errors defined above (used by error_description_r)
#define ERR_MIN 100000
#define ERR_MAX 110000
// define error codes.
enum LibError {
#define ERR(err, id, str) id = err,
#include "lib_errors.h"
// necessary because the enum would otherwise end with a comma
// (which is often tolerated but not standards compliant).
// note: we cannot rely on this being the last value (in case the
// ERR x-macros aren't arranged in order), so don't use as such.
LIB_ERROR_DUMMY
};
// generate textual description of an error code.
// stores up to <max_chars> in the given buffer.
// <err> can be one of the above error codes, POSIX ENOENT etc., or
// an OS-specific errors. if unknown, the string will be something like
// "Unknown error (65536, 0x10000)".
extern void error_description_r(int err, char* buf, size_t max_chars);
#endif // #ifndef ERRORS_H__
//-----------------------------------------------------------------------------
#ifdef ERR
// X macros: error code, symbolic name in code, user-visible string.
// error code is usually negative; positive denotes warnings.
// its absolute value must be within [ERR_MIN, ERR_MAX).
// function arguments
ERR(-100000, ERR_INVALID_PARAM, "Invalid function argument")
ERR(-100001, ERR_INVALID_HANDLE, "Invalid Handle (argument)")
ERR(-100002, ERR_BUF_SIZE, "Buffer argument too small")
// system limitations
ERR(-100020, ERR_NO_MEM, "Not enough memory")
ERR(-100021, ERR_AGAIN, "Try again later")
ERR(-100022, ERR_LIMIT, "Fixed limit exceeded")
ERR(-100023, ERR_NO_SYS, "OS doesn't provide a required API")
ERR(-100024, ERR_NOT_IMPLEMENTED, "Feature currently not implemented")
ERR(-100025, ERR_NOT_SUPPORTED, "Feature isn't and won't be supported")
ERR(-1060, ERR_TIMED_OUT, "Timed out")
// file + vfs
ERR(-100200, ERR_FILE_NOT_FOUND, "VFile not found")
ERR(-100201, ERR_PATH_NOT_FOUND, "VDir not found")
ERR(-100202, ERR_PATH_LENGTH, "Path exceeds VFS_MAX_PATH characters")
ERR(-100203, ERR_PATH_INVALID, "Path is invalid")
ERR(-100210, ERR_DIR_END, "End of directory reached (no more files)")
ERR(-100220, ERR_NOT_FILE, "Not a file")
ERR(-100230, ERR_FILE_ACCESS, "Insufficient access rights to open file")
ERR(-100231, ERR_IO, "Error during IO")
ERR(-100232, ERR_EOF, "Reading beyond end of file")
// file format
ERR(-100400, ERR_UNKNOWN_FORMAT, "Unknown file format")
ERR(-100401, ERR_INCOMPLETE_HEADER, "File header not completely read")
ERR(-100402, ERR_CORRUPTED, "File data is corrupted")
// texture
ERR(-100500, ERR_TEX_FMT_INVALID, "Invalid/unsupported texture format")
ERR(-100501, ERR_TEX_INVALID_COLOR_TYPE, "Invalid color type")
ERR(-100502, ERR_TEX_NOT_8BIT_PRECISION, "Not 8-bit channel precision")
ERR(-100503, ERR_TEX_INVALID_LAYOUT, "Unsupported texel layout, e.g. right-to-left")
ERR(-100504, ERR_TEX_COMPRESSED, "Unsupported texture compression")
ERR(+100505, WARN_TEX_INVALID_DATA, "Warning: invalid texel data encountered")
ERR(-100506, ERR_TEX_INVALID_SIZE, "Texture size is incorrect")
ERR(-100600, ERR_CPU_FEATURE_MISSING, "This CPU doesn't support a required feature")
// shaders
ERR(-100700, ERR_SHDR_CREATE, "Shader creation failed")
ERR(-100701, ERR_SHDR_COMPILE, "Shader compile failed")
ERR(-100702, ERR_SHDR_NO_SHADER, "Invalid shader reference")
ERR(-100703, ERR_SHDR_LINK, "Shader linking failed")
ERR(-100704, ERR_SHDR_NO_PROGRAM, "Invalid shader program reference")
#undef ERR
#endif // #ifdef ERR