Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit fa52f62

Browse files
committed
[[ Foundation ]] Added MCErrorThrowGenericWithMessage API.
1 parent bbdf354 commit fa52f62

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

libfoundation/include/foundation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,9 @@ MC_DLLEXPORT bool MCErrorThrowOutOfMemory(void);
26312631
// Throw a generic runtime error (one that hasn't had a class made for it yet).
26322632
// The message argument is optional (nil if no message).
26332633
MC_DLLEXPORT bool MCErrorThrowGeneric(MCStringRef message);
2634+
2635+
// Throw a generic runtime error with formatted message.
2636+
MC_DLLEXPORT bool MCErrorThrowGenericWithMessage(MCStringRef message, ...);
26342637

26352638
////////////////////////////////////////////////////////////////////////////////
26362639
//

libfoundation/src/foundation-error.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ bool MCErrorThrowGeneric(MCStringRef p_reason)
332332
return MCErrorCreateAndThrow(kMCGenericErrorTypeInfo, "reason", p_reason, nil);
333333
}
334334

335+
bool MCErrorThrowGenericWithMessage(MCStringRef p_message, ...)
336+
{
337+
va_list t_args;
338+
va_start(t_args, p_message);
339+
340+
bool t_success;
341+
t_success = MCErrorCreateAndThrowWithMessageV(kMCGenericErrorTypeInfo, p_message, t_args);
342+
343+
va_end(t_args);
344+
345+
return t_success;
346+
}
347+
335348
////////////////////////////////////////////////////////////////////////////////
336349

337350
void __MCErrorDestroy(__MCError *self)

0 commit comments

Comments
 (0)