Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions
foray_exception.hpp File Reference
#include <exception>
#include <source_location>
#include <spdlog/fmt/fmt.h>

Go to the source code of this file.

Classes

class  foray::Exception
 An extension of std::exception providing support for formatted error messages. Exceptions should always be catched via "catch (const std::exception& ex)", and thrown by value (Just use builtin static throw functions) More...
 

Namespaces

namespace  foray
 

Macros

#define FORAY_ASSERTFMT(val, fmt, ...)
 Assertion macro for formatted error messages.
 
#define FORAY_THROWFMT(fmt, ...)
 Macro for throwing an exception with formatted error message argument.
 

Typedefs

using source_location = std::source_location
 

Functions

void foray::Assert (bool condition, const source_location location=source_location::current())
 Asserts condition. Throws a generic error message if conditition is false.
 
void foray::Assert (bool condition, std::string_view message, const source_location location=source_location::current())
 Asserts condition. Throws a user defined error message if conditition is false.
 

Macro Definition Documentation

◆ FORAY_ASSERTFMT

#define FORAY_ASSERTFMT (   val,
  fmt,
  ... 
)
Value:
if(!(val)) \
{ \
const source_location __foray_location = source_location::current(); \
foray::Exception::Throw(__foray_location, fmt, __VA_ARGS__); \
}
std::source_location source_location
Definition foray_exception.hpp:8

Assertion macro for formatted error messages.

Remarks
Why is this not a function? Many use cases would cause errors if format arguments were evaluated in a case where assertion passes. A macro circumvents this problem.

◆ FORAY_THROWFMT

#define FORAY_THROWFMT (   fmt,
  ... 
)
Value:
{ \
const source_location __foray_location = source_location::current(); \
foray::Exception::Throw(__foray_location, fmt, __VA_ARGS__); \
}

Macro for throwing an exception with formatted error message argument.

Remarks
Why is this not a function? Variadic functions don't mesh with default arguments (used to catch source location). A macro can circumvent this (albeit not very gracefully)

Typedef Documentation

◆ source_location

using source_location = std::source_location