ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
exit_status.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7#include <global-params.hpp>
8
9#include <CLI/Error.hpp>
10
11#include <algorithm>
12
13namespace rux {
14
23inline int exit_code_for(int status) {
24 if (status == RuxError::SUCCESS)
25 return 0;
26 const long code = status < 0 ? -static_cast<long>(status) : status;
27 return static_cast<int>(std::clamp<long>(code, 1, 125));
28}
29
47inline void finish(int status) {
48 if (status != RuxError::SUCCESS)
49 throw CLI::RuntimeError(exit_code_for(status));
50}
51
52} // namespace rux
@ SUCCESS
void finish(int status)
Hand a run_subcommand_* status to CLI11 so that it reaches the process exit code.
int exit_code_for(const reusex::pipeline::StageResult &result)
Map a library stage outcome onto a rux exit code.