0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-29 08:54:02 +01:00

ircd:Ⓜ️🆔 Improve the validator error msg propagation; minor cleanup.

This commit is contained in:
Jason Volk 2018-03-13 15:40:22 -07:00
parent 0f5e84b2e0
commit 7deebfd344

View file

@ -277,7 +277,6 @@ const try
const rule<string_view> view_mxid const rule<string_view> view_mxid
{ {
raw[&lit(char(sigil)) > mxid] raw[&lit(char(sigil)) > mxid]
,"mxid"
}; };
string_view out; string_view out;
@ -340,7 +339,6 @@ const try
const rule<string_view> valid_mxid const rule<string_view> valid_mxid
{ {
&lit(char(sigil)) > mxid &lit(char(sigil)) > mxid
,"mxid"
}; };
const char *start{id.data()}; const char *start{id.data()};
@ -585,26 +583,16 @@ ircd::m::my(const id &id)
void void
ircd::m::validate(const id::sigil &sigil, ircd::m::validate(const id::sigil &sigil,
const string_view &id) const string_view &id)
try
{ {
id::validator(sigil, id); id::validator(sigil, id);
} }
catch(const std::exception &e)
{
throw INVALID_MXID
{
"Not a valid '%s' mxid: %s",
reflect(sigil),
e.what()
};
}
bool bool
ircd::m::valid(const id::sigil &sigil, ircd::m::valid(const id::sigil &sigil,
const string_view &id) const string_view &id)
noexcept try noexcept try
{ {
id::validator(sigil, id); validate(sigil, id);
return true; return true;
} }
catch(...) catch(...)
@ -715,7 +703,7 @@ void
ircd::m::failure(const qi::expectation_failure<const char *> &e, ircd::m::failure(const qi::expectation_failure<const char *> &e,
const string_view &goal) const string_view &goal)
{ {
auto rule const auto rule
{ {
ircd::string(e.what_) ircd::string(e.what_)
}; };