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

Commit 3722624

Browse files
committed
[[ Foundation ]] Add MCErrorReset function
This patch adds an MCErrorReset function which clears and discards any error state on the current thread.
1 parent bb8cb1b commit 3722624

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

libfoundation/include/foundation.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,12 +2904,18 @@ MC_DLLEXPORT bool MCErrorThrow(MCErrorRef error);
29042904
// Catch the current error code (on the current thread) if any and clear it.
29052905
MC_DLLEXPORT bool MCErrorCatch(MCErrorRef& r_error);
29062906

2907+
// Resets the error state on the current thread. This call is equivalent to:
2908+
// MCAutoErrorRef t_error;
2909+
// MCErrorCatach(&t_error);
2910+
MC_DLLEXPORT void MCErrorReset(void);
2911+
29072912
// Returns true if there is an error pending on the current thread.
29082913
MC_DLLEXPORT bool MCErrorIsPending(void);
29092914

29102915
// Returns any pending error (on the current thread) without clearing it.
29112916
MC_DLLEXPORT MCErrorRef MCErrorPeek(void);
29122917

2918+
29132919
// Throw an out of memory error.
29142920
MC_DLLEXPORT bool MCErrorThrowOutOfMemory(void);
29152921

libfoundation/src/foundation-error.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ bool MCErrorCatch(MCErrorRef& r_error)
408408
return true;
409409
}
410410

411+
MC_DLLEXPORT_DEF
412+
void MCErrorReset(void)
413+
{
414+
MCAutoErrorRef t_error;
415+
MCErrorCatch(&t_error);
416+
}
417+
411418
MC_DLLEXPORT_DEF
412419
MCErrorRef MCErrorPeek(void)
413420
{

0 commit comments

Comments
 (0)