PMT Renovated main-branch
Partition Manager Tool is a fast, reliable, and feature-rich CLI application for Android devices that enables advanced partition operations such as backup, flashing, erasing, information retrieval, and more.
Loading...
Searching...
No Matches
Helper::Error Class Referencefinal

A modern, throwable error class. It provides the << operator and offers usage in the std::print style of modern C++23. More...

#include <error.hpp>

Inheritance diagram for Helper::Error:
std::exception

Public Member Functions

 Error (const Error &other) noexcept
 Copy constructor.
 
template<typename... Args>
 Error (std::format_string< Args... > fmt, Args &&...args)
 Modern std::print style input field constructor.
 
template<typename T >
Error && operator<< (const T &msg) &&
 To use the << operator for receiving non-function-like inputs.
 
Erroroperator<< (std::ostream &(*msg)(std::ostream &))
 To receive function-like inputs, use the << operator.
 
Error && withCode (int _ec)
 It is used to determine the error code when an error is thrown.
 
int getErrorCode () const
 Get error code.
 
const char * what () const noexcept override
 Get error message.
 
- Public Member Functions inherited from std::exception
T exception (T... args)
 
T operator= (T... args)
 
T what (T... args)
 
T ~exception (T... args)
 

Detailed Description

A modern, throwable error class. It provides the << operator and offers usage in the std::print style of modern C++23.

void someFunction(void) {
// I will ignore the namespace in the instance of the 'Error' class.
throw Error() << "An error occurred! Error code: " << e; // With << operator.
throw Error().withCode(e) << "An error code occurred!"; // With << operator and error code specifying.
throw Error("An error occurred! Error code: {}", e); // With <format>.
throw Error("An error occurred!").withCode(e); // With <format> and error code specifying.
// Let's make things a little more interesting...
throw Error("What is that? ").withCode(e) << "Oh right, that's a error!";
}
int main(int argc, char** argv) {
try {
someFunction();
} catch (Error &e) {
// Let's assume we receive the "interesting" error message we wrote at the end.
std::cout << e.what() << " Error code: " << e.getErrorCode() << std::endl;
return e.getErrorCode();
}
return 0;
}
A modern, throwable error class. It provides the << operator and offers usage in the std::print style...
Definition error.hpp:65
Error && withCode(int _ec)
It is used to determine the error code when an error is thrown.
Definition error.hpp:97
static int getNumber()
Get a random number.
Definition random.hpp:66
T endl(T... args)

The documentation for this class was generated from the following file: