cs-midi/AH/Error/Error.hpp

41 lines
1.6 KiB
C++

#pragma once
/// @file
#include <AH/Debug/Debug.hpp>
BEGIN_AH_NAMESPACE
/// Blinks the built-in LED and loops forever on fatal error.
extern void fatalErrorExit() __attribute__((noreturn));
END_AH_NAMESPACE
#ifdef FATAL_ERRORS
#define ERROR(msg, errc) \
do { \
USING_AH_NAMESPACE; \
DEBUGFN(msg << " (0x" << hex << uppercase << errc << dec \
<< nouppercase << ')'); \
fatalErrorExit(); \
} while (0)
#else
#define ERROR(msg, errc) \
do { \
DEBUGFN(msg << " (0x" << hex << uppercase << errc << dec \
<< nouppercase << ')'); \
} while (0)
#endif
#define FATAL_ERROR(msg, errc) \
do { \
USING_AH_NAMESPACE; \
DEBUGFN(F("Fatal Error: ") << msg << " (0x" << hex << uppercase \
<< errc << dec << nouppercase << ')'); \
fatalErrorExit(); \
} while (0)