blob: 862fc7dbc53bdda4c9fd3e22921dc3f59ccec7f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/*
* 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 Kernel::KResult in mind.
#define TRY(expression) \
({ \
auto result = (expression); \
if (result.is_error()) \
return result.release_error(); \
result.release_value(); \
})
|