cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
return_code.cpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
11
13
14#include <cstdlib>
15#include <string>
16#include <utility>
17
18std::uint16_t Term::returnCode() noexcept
19{
20 static std::uint16_t code{EXIT_FAILURE};
21 const std::pair<bool, std::string> returnCode{Private::getenv("CPP_TERMINAL_BADSTATE")};
22 try
23 {
24 if(returnCode.first && (std::stoi(returnCode.second) != EXIT_SUCCESS)) { code = static_cast<std::uint16_t>(std::stoi(returnCode.second)); }
25 }
26 catch(...)
27 {
28 code = EXIT_FAILURE;
29 }
30 return code;
31}
std::uint16_t returnCode() noexcept