0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-18 09:40:12 +01:00

ircd:Ⓜ️:vm::fault: Add missing to switch; improve formatting; minor cleanup.

This commit is contained in:
Jason Volk 2023-02-18 16:59:22 -08:00
parent 0f3fea3b72
commit de1a566909
2 changed files with 28 additions and 25 deletions

View file

@ -31,13 +31,13 @@ namespace ircd::m::vm
enum ircd::m::vm::fault
:uint
{
ACCEPT = 0x00, ///< No fault.
EXISTS = 0x01, ///< Replaying existing event. (#ex)
GENERAL = 0x02, ///< General protection fault. (#gp)
INVALID = 0x04, ///< Non-conforming event format. (#ud)
AUTH = 0x08, ///< Auth rules violation. (#av)
STATE = 0x10, ///< Required state is missing (#st)
EVENT = 0x20, ///< Eval requires addl events in the ef register (#ef)
BOUNCE = 0x40, ///< The event is not needed at this time (#bo)
DONOTWANT = 0x80, ///< The event will never be needed (cache this) (#dw)
ACCEPT = 0x0000, ///< No fault.
EXISTS = 0x0001, ///< Replaying existing event. (#ex)
GENERAL = 0x0002, ///< General protection fault. (#gp)
INVALID = 0x0004, ///< Non-conforming event format. (#ud)
AUTH = 0x0008, ///< Auth rules violation. (#av)
STATE = 0x0010, ///< Required state is missing. (#st)
EVENT = 0x0020, ///< Eval requires addl events in the ef register. (#ef)
BOUNCE = 0x0040, ///< The event is not needed at this time. (#bo)
DONOTWANT = 0x0080, ///< The event will never be needed (cache this). (#dw)
};

View file

@ -109,22 +109,6 @@ noexcept
assert(retired == sequence::retired || ircd::read_only);
}
ircd::http::code
ircd::m::vm::http_code(const fault &code)
{
switch(code)
{
case fault::ACCEPT: return http::OK;
case fault::EXISTS: return http::CONFLICT;
case fault::INVALID: return http::BAD_REQUEST;
case fault::GENERAL: return http::UNAUTHORIZED;
case fault::AUTH: return http::FORBIDDEN;
case fault::STATE: return http::NOT_FOUND;
case fault::EVENT: return http::NOT_FOUND;
default: return http::INTERNAL_SERVER_ERROR;
}
}
ircd::string_view
ircd::m::vm::reflect(const enum phase &code)
{
@ -161,6 +145,25 @@ ircd::m::vm::reflect(const enum phase &code)
return "??????";
}
ircd::http::code
ircd::m::vm::http_code(const fault &code)
{
switch(code)
{
case fault::ACCEPT: return http::OK;
case fault::EXISTS: return http::CONFLICT;
case fault::INVALID: return http::BAD_REQUEST;
case fault::GENERAL: return http::UNAUTHORIZED;
case fault::AUTH: return http::FORBIDDEN;
case fault::STATE: return http::NOT_FOUND;
case fault::EVENT: return http::NOT_FOUND;
case fault::BOUNCE: break;
case fault::DONOTWANT: break;
}
return http::INTERNAL_SERVER_ERROR;
}
ircd::string_view
ircd::m::vm::reflect(const enum fault &code)
{