$line =~ s@/[*].*?[*]/@@; # strip simple single-line /* comments */
my($id);
- if ($line =~ /\bMust2?\s*\(/ || # Must(...) and Must2(...)
+ if ($line =~ /\bMust\s*\(/ || # Must(...)
$line =~ /\bTexcHere\s*\(/ || # TexcHere(...)
$line =~ /\bHere\s*\(\s*\)/) { # Here()
$line =~ s/^\s*//;
#define TexcHere(msg) TextException((msg), Here())
/// Like assert() but throws an exception instead of aborting the process
-/// and allows the caller to specify a custom exception message.
-#define Must2(condition, message) \
+/// and allows the caller to customize the exception message and location.
+/// \param description string literal describing the condition; what MUST happen
+#define Must3(condition, description, location) \
do { \
if (!(condition)) { \
- const TextException Must_ex_((message), Here()); \
+ const TextException Must_ex_(("check failed: " description), (location)); \
debugs(0, 3, Must_ex_.what()); \
throw Must_ex_; \
} \
} while (/*CONSTCOND*/ false)
/// Like assert() but throws an exception instead of aborting the process.
-#define Must(condition) Must2((condition), "check failed: " #condition)
+#define Must(condition) Must3((condition), #condition, Here())
/// Reports and swallows all exceptions to prevent compiler warnings and runtime
/// errors related to throwing class destructors. Should be used for most dtors.
debugs(24, 8, id << " finish appending " << actualSize << " bytes");
size_type newSize = length() + actualSize;
- Must2(newSize <= min(maxSize,store_->capacity-off_), "raw append overflow");
+ Must3(newSize <= min(maxSize, store_->capacity-off_), "raw append fits", Here());
len_ = newSize;
store_->size = off_ + newSize;
}
va_copy(ap, vargs);
sz = vsnprintf(space, spaceSize(), fmt, ap);
va_end(ap);
- Must2(sz >= 0, "vsnprintf() output error");
+ Must3(sz >= 0, "vsnprintf() succeeds", Here());
/* check for possible overflow */
/* snprintf on Linux returns -1 on output errors, or the size
requiredSpaceEstimate = sz*2; // TODO: tune heuristics
space = rawSpace(requiredSpaceEstimate);
sz = vsnprintf(space, spaceSize(), fmt, vargs);
- Must2(sz >= 0, "vsnprintf() output error despite increased buffer space");
+ Must3(sz >= 0, "vsnprintf() succeeds (with increased buffer space)", Here());
}
// data was appended, update internal state