Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
Error

A growing collection of error utilities. More...

Classes

class  sourcemeta::core::Error
class  sourcemeta::core::FileError< T >

Detailed Description

A growing collection of error utilities.

This functionality is included as follows:

#include <sourcemeta/core/error.h>

Class Documentation

◆ sourcemeta::core::Error

class sourcemeta::core::Error

The base class of every error this project raises. It cannot be constructed on its own, and its message is fixed at compile time.

#include <sourcemeta/core/error.h>
#include <cassert>
#include <string>
class MyError : public sourcemeta::core::Error {
public:
MyError() : sourcemeta::core::Error{"Something went wrong"} {}
};
try {
throw MyError{};
} catch (const sourcemeta::core::Error &error) {
assert(error.what() == std::string{"Something went wrong"});
}
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
Definition error_base.h:48
@ Error
Error conditions.
Definition mcp_logging.h:36
Inheritance diagram for sourcemeta::core::Error:
sourcemeta::core::CryptoError sourcemeta::core::DecimalParseError sourcemeta::core::FileViewError sourcemeta::core::GZIPError sourcemeta::core::HTTPEntropyError sourcemeta::core::HTTPError sourcemeta::core::IOFileAlreadyExistsError sourcemeta::core::IOFileNotFoundError sourcemeta::core::IOFilePermissionError sourcemeta::core::IOFilesystemError sourcemeta::core::IOIsADirectoryError sourcemeta::core::IONotADirectoryError sourcemeta::core::IOReadOutOfBoundsError sourcemeta::core::IOStreamWriteError sourcemeta::core::JSONIntegerRangeError sourcemeta::core::JSONLDError sourcemeta::core::JSONNonFiniteError sourcemeta::core::JSONParseError sourcemeta::core::JSONPathParseError sourcemeta::core::JWEParseError sourcemeta::core::JWKParseError sourcemeta::core::JWKSParseError sourcemeta::core::JWTParseError sourcemeta::core::MCPError sourcemeta::core::MarkdownError sourcemeta::core::MetapackError sourcemeta::core::NumericDivisionByZeroError sourcemeta::core::NumericInvalidOperationError sourcemeta::core::NumericOutOfMemoryError sourcemeta::core::NumericOutOfRangeError sourcemeta::core::NumericOverflowError sourcemeta::core::OAuthMetadataParseError sourcemeta::core::OAuthRegistrationParseError sourcemeta::core::OIDCMetadataParseError sourcemeta::core::OIDCRegistrationParseError sourcemeta::core::OpenAPIBundleLimitError sourcemeta::core::OpenAPIError sourcemeta::core::OpenAPIFrameLimitError sourcemeta::core::OpenAPIReferenceError sourcemeta::core::OpenAPIResolutionError sourcemeta::core::OptionsError sourcemeta::core::ParallelThreadError sourcemeta::core::PointerParseError sourcemeta::core::ProcessProgramNotFoundError sourcemeta::core::ProcessSpawnError sourcemeta::core::PunycodeError sourcemeta::core::SchemaAnchorCollisionError sourcemeta::core::SchemaContainerError sourcemeta::core::SchemaDialectImpossibleError sourcemeta::core::SchemaError sourcemeta::core::SchemaFrameError sourcemeta::core::SchemaFrameLimitError sourcemeta::core::SchemaKeywordError sourcemeta::core::SchemaReferenceError sourcemeta::core::SchemaReferenceObjectResourceError sourcemeta::core::SchemaResolutionError sourcemeta::core::SchemaUnknownBaseDialectError sourcemeta::core::SchemaUnknownDialectError sourcemeta::core::SchemaVocabularyError sourcemeta::core::SemVerOverflowError sourcemeta::core::SemVerParseError sourcemeta::core::URIError sourcemeta::core::URIParseError sourcemeta::core::URITemplateExpansionError sourcemeta::core::URITemplateParseError sourcemeta::core::URITemplateRouterDuplicateOperationIdError sourcemeta::core::URITemplateRouterInvalidOperationIdError sourcemeta::core::URITemplateRouterInvalidSegmentError sourcemeta::core::URITemplateRouterReadError sourcemeta::core::URITemplateRouterSaveError sourcemeta::core::URITemplateRouterVariableMismatchError sourcemeta::core::VarintParseError sourcemeta::core::YAMLError sourcemeta::core::YAMLParseError

Public Member Functions

auto message () const noexcept -> StaticString

Protected Member Functions

 Error (const StaticString message) noexcept
 Construct the error given its message.

Member Function Documentation

◆ message()

auto sourcemeta::core::Error::message ( ) const -> StaticString
inlinenodiscardnoexcept

Get the message in the form another error can take it, which is how a handler raises a different error without restating the reason.

#include <sourcemeta/core/error.h>
#include <cassert>
#include <string>
class MyError : public sourcemeta::core::Error {
public:
MyError() : sourcemeta::core::Error{"Something went wrong"} {}
};
class MyFileError : public sourcemeta::core::Error {
public:
: sourcemeta::core::Error{message} {}
};
try {
throw MyError{};
} catch (const sourcemeta::core::Error &error) {
const MyFileError wrapped{error.message()};
assert(wrapped.what() == std::string{"Something went wrong"});
}
auto message() const noexcept -> StaticString
Definition error_base.h:78
Definition text_static_string.h:20

◆ sourcemeta::core::FileError

class sourcemeta::core::FileError
template<typename T>
class sourcemeta::core::FileError< T >

A wrapper that decorates an arbitrary exception type with a file path.

#include <sourcemeta/core/error.h>
#include <stdexcept>
"/tmp/foo.json", "something went wrong");
Definition error_file.h:19
Inheritance diagram for sourcemeta::core::FileError< T >:

Public Member Functions

template<typename... Args>
 FileError (std::filesystem::path path, Args &&...args)
auto path () const noexcept -> const std::filesystem::path &
 The offending file path.

Constructor & Destructor Documentation

◆ FileError()

template<typename T>
template<typename... Args>
sourcemeta::core::FileError< T >::FileError ( std::filesystem::path path,
Args &&... args )
inline

Construct the error given the offending file path and the underlying exception arguments.