33#ifndef _SIR_ERRORS_H_INCLUDED
34# define _SIR_ERRORS_H_INCLUDED
36# include "sir/types.h"
73# if defined(__cplusplus)
79# define _sir_mkerror(code) (((uint32_t)((code) & 0x7fffffffU) << 16) | 0x80000000U)
83bool _sir_validerror(uint32_t err) {
84 uint32_t masked = err & 0x8fffffffU;
85 return masked >= 0x80000000U && masked <= 0x8fff0000U;
90uint16_t _sir_geterrcode(uint32_t err) {
91 return (err >> 16) & 0x7fffU;
95# define _SIR_E_NOERROR _sir_mkerror(SIR_E_NOERROR)
96# define _SIR_E_NOTREADY _sir_mkerror(SIR_E_NOTREADY)
97# define _SIR_E_ALREADY _sir_mkerror(SIR_E_ALREADY)
98# define _SIR_E_DUPITEM _sir_mkerror(SIR_E_DUPITEM)
99# define _SIR_E_NOITEM _sir_mkerror(SIR_E_NOITEM)
100# define _SIR_E_NOROOM _sir_mkerror(SIR_E_NOROOM)
101# define _SIR_E_OPTIONS _sir_mkerror(SIR_E_OPTIONS)
102# define _SIR_E_LEVELS _sir_mkerror(SIR_E_LEVELS)
103# define _SIR_E_TEXTSTYLE _sir_mkerror(SIR_E_TEXTSTYLE)
104# define _SIR_E_STRING _sir_mkerror(SIR_E_STRING)
105# define _SIR_E_NULLPTR _sir_mkerror(SIR_E_NULLPTR)
106# define _SIR_E_INVALID _sir_mkerror(SIR_E_INVALID)
107# define _SIR_E_NODEST _sir_mkerror(SIR_E_NODEST)
108# define _SIR_E_UNAVAIL _sir_mkerror(SIR_E_UNAVAIL)
109# define _SIR_E_INTERNAL _sir_mkerror(SIR_E_INTERNAL)
110# define _SIR_E_COLORMODE _sir_mkerror(SIR_E_COLORMODE)
111# define _SIR_E_TEXTATTR _sir_mkerror(SIR_E_TEXTATTR)
112# define _SIR_E_TEXTCOLOR _sir_mkerror(SIR_E_TEXTCOLOR)
113# define _SIR_E_PLUGINBAD _sir_mkerror(SIR_E_PLUGINBAD)
114# define _SIR_E_PLUGINDAT _sir_mkerror(SIR_E_PLUGINDAT)
115# define _SIR_E_PLUGINVER _sir_mkerror(SIR_E_PLUGINVER)
116# define _SIR_E_PLUGINERR _sir_mkerror(SIR_E_PLUGINERR)
117# define _SIR_E_PLATFORM _sir_mkerror(SIR_E_PLATFORM)
118# define _SIR_E_UNKNOWN _sir_mkerror(SIR_E_UNKNOWN)
120bool __sir_seterror(uint32_t err,
const char* func,
const char* file, uint32_t line);
121# define _sir_seterror(err) __sir_seterror(err, __func__, __file__, __LINE__)
123void __sir_setoserror(
int code,
const char* msg,
const char* func,
124 const char* file, uint32_t line);
127bool __sir_handleerr(
int code,
const char* func,
const char* file, uint32_t line);
128# define _sir_handleerr(code) __sir_handleerr(code, __func__, __file__, __LINE__)
131void _sir_invalidparameter(
const wchar_t* expr,
const wchar_t* func,
const wchar_t* file,
132 unsigned int line, uintptr_t reserved);
134bool __sir_handlewin32err(DWORD code,
const char* func,
const char* file, uint32_t line);
135# define _sir_handlewin32err(code) __sir_handlewin32err((DWORD)code, __func__, __file__, __LINE__)
146void _sir_reset_tls_error(
void);
148# if defined(SIR_SELFLOG)
150PRINTF_FORMAT_ATTR(4, 5)
151void __sir_selflog(const
char* func, const
char* file, uint32_t line, PRINTF_FORMAT const
char* format, ...);
152# define _sir_selflog(...) __sir_selflog(__func__, __file__, __LINE__, __VA_ARGS__)
155void __sir_fakefunc(
const char* format, ...) { (void)format; }
156# define _sir_selflog(...) __sir_fakefunc(__VA_ARGS__)
159# if defined(__cplusplus)
#define SIR_MAXERROR
The maximum size, in characters, of an error message.
Definition config.h:419
sir_errorcode
Error codes.
Definition errors.h:44
@ SIR_E_STRING
Invalid string argument.
Definition errors.h:54
@ SIR_E_TEXTCOLOR
Text color is invalid for mode.
Definition errors.h:62
@ SIR_E_PLATFORM
Platform error code %d: %s.
Definition errors.h:67
@ SIR_E_DUPITEM
Item already managed by libsir.
Definition errors.h:48
@ SIR_E_INTERNAL
An internal error has occurred.
Definition errors.h:59
@ SIR_E_UNAVAIL
Feature is disabled or unavailable.
Definition errors.h:58
@ SIR_E_TEXTSTYLE
Text style is invalid.
Definition errors.h:53
@ SIR_E_OPTIONS
Option flags are invalid.
Definition errors.h:51
@ SIR_E_NOITEM
Item not managed by libsir.
Definition errors.h:49
@ SIR_E_PLUGINVER
Plugin interface version unsupported.
Definition errors.h:65
@ SIR_E_UNKNOWN
Unknown error.
Definition errors.h:68
@ SIR_E_PLUGINDAT
Data produced by plugin is invalid.
Definition errors.h:64
@ SIR_E_NOTREADY
libsir has not been initialized
Definition errors.h:46
@ SIR_E_NULLPTR
NULL pointer argument.
Definition errors.h:55
@ SIR_E_LEVELS
Level flags are invalid.
Definition errors.h:52
@ SIR_E_ALREADY
libsir is already initialized
Definition errors.h:47
@ SIR_E_PLUGINERR
Plugin reported failure.
Definition errors.h:66
@ SIR_E_COLORMODE
Color mode is invalid.
Definition errors.h:60
@ SIR_E_PLUGINBAD
Plugin module is malformed.
Definition errors.h:63
@ SIR_E_INVALID
Invalid argument.
Definition errors.h:56
@ SIR_E_NODEST
No destinations registered for level.
Definition errors.h:57
@ SIR_E_NOROOM
Maximum number of items already stored.
Definition errors.h:50
@ SIR_E_NOERROR
The operation completed successfully.
Definition errors.h:45
@ SIR_E_TEXTATTR
Text attributes are invalid.
Definition errors.h:61
Information about an error that occurred.
Definition types.h:150