Files
ladybird/AK
Andreas Kling b4d8e166d8 AK: Add a TRY(expression) macro to simplify the unwrap-or-return pattern
The way we use classes like Kernel::KResultOr<T> and AK::Result<T, E>
makes checking for errors (and short-circuiting returns) quite verbose.

This patch adds a new TRY(expression) macro that either evaluates to
the released result of the expression if successful, or returns the
error if not.

Before:

    auto foo_or_error = get_foo();
    if (foo_or_error.is_error())
        return foo_or_error.release_error();
    auto foo = foo_or_error.release_value();

After:

    auto foo = TRY(get_foo());

The macro uses a GNU C++ extension which is supported by GCC, Clang,
Intel C++, and possibly others. It's not *ideal*, but since it makes our
codebase considerably nicer, let's try(!) it out. :^)

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2021-09-05 14:08:12 +02:00
..
2021-06-09 23:05:32 +04:30
2021-05-19 23:37:10 +01:00
2021-07-14 11:26:34 +04:30
2021-07-12 19:05:17 +01:00
2021-08-24 16:37:28 +02:00
2021-08-07 12:48:22 +02:00
2021-08-08 10:55:36 +02:00
2021-06-24 09:27:13 +02:00
2021-05-14 22:24:02 +02:00
2021-05-14 22:24:02 +02:00
2021-08-07 15:21:58 +02:00
2021-07-22 23:33:21 +02:00
2021-05-26 16:36:53 +04:30
2021-08-31 16:38:22 +02:00
2021-08-19 19:15:00 +01:00
2021-08-27 23:35:27 +04:30
2021-06-08 12:15:04 +02:00
2021-04-29 22:23:52 +02:00
2021-06-24 00:38:23 +02:00
2021-04-23 16:46:57 +02:00