namespace axl::err

namespace err {

// enums

enum StdErrorCode;

// structs

struct ErrorHdr;

// classes

class Errno;
class ErrnoProvider;
class Error;
class ErrorMgr;
class ErrorProvider;
class ErrorRef;
class ErrorRouter;
class SizeOfError;
class StdErrorProvider;

// global variables

AXL_SELECT_ANY const sl::Guid g_stdErrorGuid = sl::g_nullGuid;
AXL_SELECT_ANY const ErrorHdr g_noError = {    sizeof(ErrorHdr),  g_stdErrorGuid,    StdErrorCode_NoError, };

// global functions

AXL_SL_DEFINE_GUID(
    g_errnoGuid,
    0x25a6a7b5,
    0xf662,
    0x48ae,
    0xbc,
    0xb6,
    0x9a,
    0x5c,
    0xb5,
    0xce,
    0x5b,
    0xb9
    );

size_t
setErrno(int code);

ErrorRef
getLastError();

size_t
setError(const ErrorRef& error);

size_t
pushError(const ErrorRef& error);

sl::String
getLastErrorDescription();

Error
getLastSystemError();

sl::String
getLastSystemErrorDescription();

template <typename Pack>
size_t
setPackError_va(
    const sl::Guid& guid,
    uint_t code,
    axl_va_list va
    );

template <typename Pack>
size_t
setPackError(
    const sl::Guid& guid,
    uint_t code,
    ...
    );

template <typename Pack>
size_t
pushPackError_va(
    const sl::Guid& guid,
    uint_t code,
    axl_va_list va
    );

template <typename Pack>
size_t
pushPackError(
    const sl::Guid& guid,
    uint_t code,
    ...
    );

size_t
setFormatError_va(
    const sl::Guid& guid,
    uint_t code,
    const char* formatString,
    axl_va_list va
    );

size_t
setFormatError(
    const sl::Guid& guid,
    uint_t code,
    const char* formatString,
    ...
    );

size_t
pushFormatError_va(
    const sl::Guid& guid,
    uint_t code,
    const char* formatString,
    axl_va_list va
    );

size_t
pushFormatError(
    const sl::Guid& guid,
    uint_t code,
    const char* formatString,
    ...
    );

size_t
setError(
    const sl::Guid& guid,
    uint_t code
    );

size_t
pushError(
    const sl::Guid& guid,
    uint_t code
    );

size_t
setFormatStringError_va(
    const char* formatString,
    axl_va_list va
    );

size_t
setFormatStringError(
    const char* formatString,
    ...
    );

size_t
pushFormatStringError_va(
    const char* formatString,
    axl_va_list va
    );

size_t
pushFormatStringError(
    const char* formatString,
    ...
    );

template <typename T>
T
fail(
    T failResult,
    const ErrorRef& error
    );

bool
fail(const ErrorRef& error);

size_t
setLastSystemError();

template <typename T>
T
failWithLastSystemError(T failResult);

bool
failWithLastSystemError();

template <typename T>
T
completeWithSystemError(
    T result,
    T failResult,
    uint_t errorCode
    );

bool
completeWithSystemError(
    int result,
    uint_t errorCode
    );

template <typename T>
T
complete(
    T result,
    T failResult
    );

bool
complete(int result);

ErrorMgr*
getErrorMgr();

void
setOutOfMemoryError();

} // namespace err