matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
Errors.hpp File Reference

Defines Error, UserError, and EngineError classes, along with macros for error handling. More...

#include <source_location>
#include <string>
#include <utility>
#include <format>
Include dependency graph for Errors.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  engine::util::Error
 Base class for all errors. More...
 
class  engine::util::EngineError
 Represents an error that occurred in the engine. More...
 
class  engine::util::UserError
 Represents an error that occurred in the user's code. More...
 

Namespaces

namespace  engine
 
namespace  engine::util
 

Macros

#define RG_GUARANTEE(expr, msg, ...)
 Guarantees that an expression is true. If it is not, an engine::util::EngineError is thrown.

 
#define RG_SHOULD_NOT_REACH_HERE(msg, ...)
 Guarantees that a path should not be reached. If it is reached, an engine::util::EngineError is thrown.
 
#define RG_UNIMPLEMENTED(msg, ...)
 Path is not implemented. If it is implemented, an engine::util::EngineError is thrown.
 
#define RG_ENGINE_ERROR(type, msg, ...)
 Throws an engine::util::EngineError.
 

Detailed Description

Defines Error, UserError, and EngineError classes, along with macros for error handling.

Macro Definition Documentation

◆ RG_GUARANTEE

#define RG_GUARANTEE (   expr,
  msg,
  ... 
)
Value:
do { \
if (!(expr)) { \
throw engine::util::EngineError(engine::util::EngineError::Type::GuaranteeViolation, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
} \
} while (0)
Represents an error that occurred in the engine.
Definition Errors.hpp:67
@ GuaranteeViolation
The error that occurs when a guarantee is violated.

Guarantees that an expression is true. If it is not, an engine::util::EngineError is thrown.

Parameters
exprThe expression to guarantee.
msgThe error message.
...The arguments to the error message.

◆ RG_SHOULD_NOT_REACH_HERE

#define RG_SHOULD_NOT_REACH_HERE (   msg,
  ... 
)
Value:
do { \
throw engine::util::EngineError(engine::util::EngineError::Type::ShouldNotReachHere, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
} while (0)
@ ShouldNotReachHere
The error that occurs when a function should not reach a certain point. Use this to mark a path that ...

Guarantees that a path should not be reached. If it is reached, an engine::util::EngineError is thrown.

Parameters
msgThe error message.
...The arguments to the error message.

◆ RG_UNIMPLEMENTED

#define RG_UNIMPLEMENTED (   msg,
  ... 
)
Value:
do { \
throw engine::util::EngineError(engine::util::EngineError::Type::Unimplemented, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
} while (0)
@ Unimplemented
The error that occurs when a function is not implemented. Use this during development to mark a funct...

Path is not implemented. If it is implemented, an engine::util::EngineError is thrown.

Parameters
msgThe error message.
...The arguments to the error message.

◆ RG_ENGINE_ERROR

#define RG_ENGINE_ERROR (   type,
  msg,
  ... 
)
Value:
do { \
throw engine::util::EngineError(type, std::format(msg, ##__VA_ARGS__), std::source_location::current()); \
} while(0)

Throws an engine::util::EngineError.

Parameters
typeThe type of the engine error.
msgThe error message.
...The arguments to the error message.