mirror of
https://github.com/matrix-construct/construct
synced 2024-12-30 17:34:04 +01:00
ircd: Add exception message generation bypass constructor.
This commit is contained in:
parent
dffb39f8cc
commit
2c231ac187
2 changed files with 18 additions and 4 deletions
|
@ -52,6 +52,8 @@ struct exception
|
|||
:std::exception
|
||||
{
|
||||
protected:
|
||||
IRCD_OVERLOAD(generate_skip)
|
||||
|
||||
char buf[BUFSIZE];
|
||||
|
||||
ssize_t generate(const char *const &name, const char *const &fmt, va_list ap) noexcept;
|
||||
|
@ -63,7 +65,7 @@ struct exception
|
|||
return buf;
|
||||
}
|
||||
|
||||
exception() noexcept
|
||||
exception(const generate_skip_t = {}) noexcept
|
||||
{
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
@ -106,24 +108,36 @@ struct name \
|
|||
:parent \
|
||||
{ \
|
||||
name(const char *const fmt = " ", ...) noexcept AFP(2, 3) \
|
||||
:parent{generate_skip} \
|
||||
{ \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
generate(#name, fmt, ap); \
|
||||
va_end(ap); \
|
||||
} \
|
||||
};
|
||||
\
|
||||
name(const generate_skip_t) noexcept \
|
||||
:parent{generate_skip} \
|
||||
{ \
|
||||
} \
|
||||
}; \
|
||||
|
||||
#define IRCD_EXCEPTION_HIDENAME(parent, name) \
|
||||
struct name \
|
||||
:parent \
|
||||
{ \
|
||||
name(const char *const fmt = " ", ...) noexcept AFP(2, 3) \
|
||||
name(const char *const fmt, ...) noexcept AFP(2, 3) \
|
||||
parent{generate_skip_t} \
|
||||
{ \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
generate(fmt, ap); \
|
||||
va_end(ap); \
|
||||
} \
|
||||
\
|
||||
name(const generate_skip_t = {}) noexcept \
|
||||
:parent{generate_skip} \
|
||||
{ \
|
||||
} \
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ noexcept
|
|||
{
|
||||
size_t size(0);
|
||||
const bool empty(!fmt || !fmt[0] || fmt[0] == ' ');
|
||||
size = rb_strlcpy(buf, name, sizeof(buf));
|
||||
size = rb_strlcat(buf, name, sizeof(buf));
|
||||
size = rb_strlcat(buf, empty? "." : ": ", sizeof(buf));
|
||||
if(size < sizeof(buf))
|
||||
size += vsnprintf(buf + size, sizeof(buf) - size, fmt, ap);
|
||||
|
|
Loading…
Reference in a new issue