Exception types

This page lists the exception types thrown by BLACK in many situations. BLACK only ever throws exceptions of types listed in this page, or standard exception types thrown by the standard library.

class exception : public std::logic_error

Base class for all the exception types thrown by BLACK.

class bad_unreachable : public exception

Exception type thrown by black_unreachable in case of failure.

Constructor:
bad_unreachable(const char *filename, size_t line)
Parameters:
Members:
std::string_view filename() const
Returns:

the name of the file of the black_unreachable call.

size_t line() const
Returns:

the line of the black_unreachable call.

class bad_assert : public exception

Exception type thrown by black_assert in case of failure.

Constructor:
bad_assert(const char *filename, size_t line, const char *expression)
Parameters:
  • filename – the name of the file of the failed black_assert call.

  • line – the line of the failed black_assert call.

  • expression – a string representation of the asserted expression of the failed black_assert call.

Members:
std::string_view filename() const
Returns:

the name of the file of the failed black_assert call.

size_t line() const
Returns:

the line of the failed black_assert call.

std::string_view expression() const
Returns:

a string representation of the asserted expression of the failed black_assert call.

class bad_assumption : public bad_assert

Exception type thrown by black_assume in case of failure.

Constructor:
bad_assumption(const char *function, const char *filename, size_t line, std::source_location const &loc, const char *expression, const char *message)
Parameters:
  • function – the name of the function that contains the failed black_assume call.

  • filename – the name of the file of the failed black_assert call.

  • line – the line of the failed black_assert call.

  • locstd::source_location of the failed black_assume call.

  • expression – a string representation of the asserted expression of the failed black_assert call.

  • message – the message associated with the failed black_assume call.

Members:
std::string_view function() const
Returns:

the name of the function that contains the failed black_assume call.

std::string_view message() const
Returns:

the message associated with the failed black_assume call.