79 [[nodiscard]] constexpr std::string_view
name() const noexcept;
80 [[nodiscard]] constexpr std::string_view
message() const noexcept;
82 [[nodiscard]] constexpr
bool is_natural() const noexcept {
155 return "unknown_category";
162 return "invalid_hex";
164 return "invalid_hex_length";
166 return "invalid_fixed_size";
172 return "narrowing_overflow";
174 return "division_by_zero";
176 return "bit_index_out_of_range";
178 return "range_violation";
180 return "empty_input";
182 return "size_mismatch";
184 return "missing_value";
186 return "invalid_symbol";
188 return "unsupported_symbol";
190 return "uninitialized_state";
192 return "index_out_of_range";
194 return "invalid_dimensions";
196 return "non_boolean_value";
198 return "equation_mismatch";
200 return "binding_mismatch";
202 return "io_open_failed";
204 return "io_write_failed";
206 return "entropy_unavailable";
208 return "backend_rejected_input";
210 return "hash_to_curve_exhausted";
212 return "unexpected_size";
214 return "generator_order_check_failed";
216 return "internal_mismatch";
218 return "transcript_check_failed";
220 return "unknown_error";
227 return "hex input contains a non-hexadecimal character";
229 return "hex input has an invalid length";
231 return "input does not have the required fixed size";
233 return "operation overflowed the target representation";
235 return "operation underflowed the target representation";
237 return "narrowing conversion would discard non-zero bits";
239 return "division by zero is not permitted";
241 return "bit index is outside the valid range";
243 return "input is outside the documented valid range";
245 return "input must not be empty";
247 return "related inputs do not have matching sizes";
249 return "required value is missing";
251 return "symbol encoding is malformed";
253 return "symbol is well-formed but not supported";
255 return "object must be initialized before this operation";
257 return "index is outside the valid range";
259 return "inputs imply an invalid shape or dimension";
261 return "value violates a required boolean constraint";
263 return "value violates a required equality constraint";
265 return "prepared state is bound to a different secret, message, or topic";
267 return "unable to open the requested file or stream";
269 return "unable to write the requested file or stream";
271 return "unable to obtain secure operating-system randomness";
273 return "the cryptographic backend rejected the supplied input";
275 return "hash-to-curve sampling exhausted all retry attempts";
277 return "backend returned an unexpected serialized size";
279 return "fixed generator failed its subgroup order check";
281 return "internal consistency check failed";
283 return "internally generated transcript failed validation";
285 return "unknown error";
320#define PURIFY_DETAIL_CONCAT_IMPL(x, y) x##y
321#define PURIFY_DETAIL_CONCAT(x, y) PURIFY_DETAIL_CONCAT_IMPL(x, y)
329#define PURIFY_RETURN_IF_ERROR(expr, context) \
330 PURIFY_DETAIL_RETURN_IF_ERROR_IMPL(PURIFY_DETAIL_CONCAT(_purify_status_, __COUNTER__), expr, context)
338#define PURIFY_ASSIGN_OR_RETURN(lhs, expr, context) \
339 PURIFY_DETAIL_ASSIGN_OR_RETURN_IMPL(PURIFY_DETAIL_CONCAT(_purify_result_, __COUNTER__), lhs, expr, context)
341#define PURIFY_DETAIL_RETURN_IF_ERROR_IMPL(status_name, expr, context) \
342 auto status_name = (expr); \
343 if (!status_name.has_value()) \
344 return ::purify::unexpected_error(status_name.error(), context)
346#define PURIFY_DETAIL_ASSIGN_OR_RETURN_IMPL(result_name, lhs, expr, context) \
347 auto result_name = (expr); \
348 if (!result_name.has_value()) \
349 return ::purify::unexpected_error(result_name.error(), context); \
350 lhs = std::move(*result_name)
Purify result carrier that either holds a value or an error.
Stable public expected-style types used by Purify.
ErrorCategory
High-level classification for all recoverable Purify errors.
constexpr Unexpected< Error > unexpected_error(ErrorCode code, const char *context=nullptr)
Constructs an unexpected Error value from a machine-readable code.
ErrorCode
Machine-readable error codes shared across the library.
@ GeneratorOrderCheckFailed
constexpr std::string_view to_string(ErrorCategory category) noexcept
Returns a stable programmatic name for an error category.
constexpr std::string_view error_message(ErrorCode code) noexcept
Returns the human-facing description for an error code.
constexpr ErrorCategory error_category(ErrorCode code) noexcept
Returns the high-level category for a concrete error code.
Compact error object returned by checked APIs.
constexpr bool is_usage_error() const noexcept
constexpr bool is_natural() const noexcept
constexpr std::string_view name() const noexcept
constexpr std::string_view message() const noexcept
constexpr auto operator<=>(const Error &) const =default
constexpr ErrorCategory category() const noexcept
constexpr bool is_internal() const noexcept