mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
79fa9765ca
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
18 lines
607 B
C
18 lines
607 B
C
/*
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// NOTE: This macro works with any result type that has the expected APIs.
|
|
// It's designed with AK::Result and AK::Error in mind.
|
|
|
|
#define TRY(expression) \
|
|
({ \
|
|
auto _temporary_result = (expression); \
|
|
if (_temporary_result.is_error()) \
|
|
return _temporary_result.release_error(); \
|
|
_temporary_result.release_value(); \
|
|
})
|