#ifndef KEKS_ERR_H
#define KEKS_ERR_H

// TEXINFO: KEKSErr
// @deftp {Data type} {enum KEKSErr}
// Errors are just a predefined enumeration value.
// @table @code
// @item KEKSErrInvalid
//     Unset error, must be never met.
// @item KEKSErrNo
//     No error, everything is good.
// @item KEKSErrNotEnough
//     Not enough data. Atom's @code{.off} must contain how much.
// @item KEKSErrUnknownType,    // unknown atom's type
//     Unknown atom's type.
// @item KEKSErrLenTooBig,
//     Too long string (>1<<60), can not be decoded.
// @item KEKSErrBadUTF8
//     Invalid UTF-8 codepoint or zero byte met.
// @item KEKSErrIntNonMinimal
//     Non minimal integer encoding.
// @item KEKSErrBlobBadAtom
//     Blob contains unexpected atom.
// @item KEKSErrBlobBadChunkLen
//     Blob contains chunk with invalid length.
// @item KEKSErrTAI64TooBig
//     Too large TAI64 value, out-of-bounds.
// @item KEKSErrTAI64BadNsec
//     Invalid TAI64 nanoseconds value.
// @item KEKSErrTAI64BadAsec
//     Invalid TAI64 attoseconds value.
// @item KEKSErrMapBadKey
//     Either bad type of map's key, or it is empty.
// @item KEKSErrMapUnordered
//     Unordered map keys.
// @item KEKSErrNoMem
//     Not enough memory for allocation.
// @item KEKSErrUnsatisfiedSchema
//     Unsatisfied structure's schema.
// @item KEKSErrDeepRecursion
//     Too deep recursion involved during parsing.
// @item KEKSErrUnexpectedEOC
//     Unexpected EOC met.
// @item KEKSErrBadMagic
//     Wrong magic value.
// @item KEKSErrFloatNonInt
//     FLOAT contains non-INT element.
// @end table
// @end deftp
enum KEKSErr {
    KEKSErrInvalid = 0,
    KEKSErrNo = 1,
    KEKSErrNotEnough,
    KEKSErrUnknownType,
    KEKSErrLenTooBig,
    KEKSErrBadUTF8,
    KEKSErrIntNonBin,
    KEKSErrIntNonMinimal,
    KEKSErrBlobBadAtom,
    KEKSErrBlobBadChunkLen,
    KEKSErrTAI64TooBig,
    KEKSErrTAI64BadNsec,
    KEKSErrTAI64BadAsec,
    KEKSErrTAI64InPast,
    KEKSErrTAI64IsLeap,
    KEKSErrTAI64NonMinimal,
    KEKSErrMapBadKey,
    KEKSErrMapUnordered,
    KEKSErrNoMem,
    KEKSErrUnsatisfiedSchema,
    KEKSErrDeepRecursion,
    KEKSErrUnexpectedEOC,
    KEKSErrBadMagic,
    KEKSErrFloatNonInt,
};

// TEXINFO: KEKSErr2Str
// @deftypefun {const char *} KEKSErr2Str (const enum KEKSErr)
// Get human-readable string of the error.
// @end deftypefun
const char *
KEKSErr2Str(const enum KEKSErr);

#endif // KEKS_ERR_H
