throw_handler

The throw_handler simply throws a ztd::text::encoding_error as an exception. This should only EVER be used for pre-verified, trusted input sources, debugging purposes, or similar; malformed text is a common enough occurrence that throwing errors by default or using this handler by default is a bad idea in almost every way.

Throwing on encoding, decoding, and other errors can easily result in Denial of Service target points if this is used in conjunction with user or untrusted input sources.

constexpr throw_handler_t ztd::text::throw_handler = {}

An instance of throw_handler_t for ease of use.

class ztd::text::throw_handler_t

An error handler that throws on any encode operation failure.

Remark

This class absolutely should not be used unless the user is prepared to handle spurious failure, especially for text processing that deals with input vectors. This can result in many exceptions being thrown, which for resource-intensive applications could cause issues and result in Denial of Service by way of repeated, unhandled, and unexpected failure.

Public Functions

template<typename _Encoding, typename _InputRange, typename _OutputRange, typename _State, typename _InputProgress, typename _OutputProgress>
inline constexpr encode_result<_InputRange, _OutputRange, _State> operator()(const _Encoding&, encode_result<_InputRange, _OutputRange, _State> __result, const _InputProgress&, const _OutputProgress&) const noexcept(false)

Throws a ztd::text::encoding_error as an exception on an encode failure.

template<typename _Encoding, typename _InputRange, typename _OutputRange, typename _State, typename _InputProgress, typename _OutputProgress>
inline constexpr decode_result<_InputRange, _OutputRange, _State> operator()(const _Encoding&, decode_result<_InputRange, _OutputRange, _State> __result, const _InputProgress&, const _OutputProgress&) const noexcept(false)

Throws a ztd::text::encoding_error code as an exception on a decode failure.