retinify
0.1.7
Real-Time AI Stereo Vision Library
Loading...
Searching...
No Matches
nothrow.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) 2025 Sensui Yagi. All rights reserved.
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include <exception>
7
#include <type_traits>
8
#include <utility>
9
10
#include "
retinify/logging.hpp
"
11
#include "
retinify/status.hpp
"
12
13
namespace
retinify
14
{
23
template
<
typename
Function>
auto
NoThrow
(Function &&function)
noexcept
->
Status
24
{
25
static_assert
(std::is_same_v<std::invoke_result_t<Function>,
Status
>,
"NoThrow requires Function to return Status"
);
26
27
try
28
{
29
return
std::forward<Function>(function)();
30
}
31
catch
(
const
std::exception &ex)
32
{
33
LogError
(ex.what());
34
return
Status
{
StatusCategory::RETINIFY
,
StatusCode::FAIL
};
35
}
36
catch
(...)
37
{
38
LogError
(
"Unknown exception caught"
);
39
return
Status
{
StatusCategory::RETINIFY
,
StatusCode::FAIL
};
40
}
41
}
42
}
// namespace retinify
retinify::Status
This class represents the status of an operation in the retinify library.
Definition
status.hpp:51
logging.hpp
retinify
Definition
colormap.hpp:13
retinify::StatusCategory::RETINIFY
@ RETINIFY
Retinify-internal category.
retinify::LogError
RETINIFY_API void LogError(const char *message, std::source_location location=std::source_location::current()) noexcept
Logs an error message.
retinify::StatusCode::FAIL
@ FAIL
Operation failed.
retinify::NoThrow
auto NoThrow(Function &&function) noexcept -> Status
Executes a function and converts any exception into a Status.
Definition
nothrow.hpp:23
status.hpp
retinify
include
retinify
nothrow.hpp
Generated by
1.9.8