AK: Use ErrorOr::ErrorType in Json helpers

This commit is contained in:
Hendiadyoin1
2025-03-06 15:07:01 +01:00
committed by Nico Weber
parent 920b840a08
commit aa71d4f848
3 changed files with 11 additions and 2 deletions

View File

@@ -16,7 +16,10 @@ namespace AK {
class JsonArray {
template<typename Callback>
using CallbackErrorType = decltype(declval<Callback>()(declval<JsonValue const&>()).release_error());
using CallbackErrorType = decltype(declval<Callback>()(declval<JsonValue const&>()))::ErrorType;
static_assert(SameAs<CallbackErrorType<ErrorOr<void> (*)(JsonValue const&)>, Error>);
static_assert(SameAs<ErrorOr<void, CallbackErrorType<ErrorOr<void> (*)(JsonValue const&)>>, ErrorOr<void>>);
public:
JsonArray() = default;

View File

@@ -20,7 +20,10 @@ namespace AK {
class JsonObject {
template<typename Callback>
using CallbackErrorType = decltype(declval<Callback>()(declval<ByteString const&>(), declval<JsonValue const&>()).release_error());
using CallbackErrorType = decltype(declval<Callback>()(declval<ByteString const&>(), declval<JsonValue const&>()))::ErrorType;
static_assert(SameAs<CallbackErrorType<ErrorOr<void> (*)(ByteString const&, JsonValue const&)>, Error>);
static_assert(SameAs<ErrorOr<void, CallbackErrorType<ErrorOr<void> (*)(ByteString const&, JsonValue const&)>>, ErrorOr<void>>);
public:
JsonObject();

View File

@@ -327,6 +327,9 @@ struct CustomError {
template<typename T>
class CustomErrorOr {
public:
using ResultType = T;
using ErrorType = CustomError;
CustomErrorOr(T)
: m_is_error(false)
{