MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Error.Fwd.h
Go to the documentation of this file.
1/** @noop License Comment
2 * @file
3 * @copyright
4 * This Source Code is subject to the terms of the Mozilla Public License, v2.0.
5 * If a copy of the MPL was not distributed with this file You can obtain one at
6 * https://mozilla.org/MPL/2.0/
7 *
8 * @author David Mórász
9 * @date 2025
10 */
11
12#pragma once
13
14#include "CoreMinimal.h"
15#include "Mcro/Concepts.h"
16
17/** Contains utilities for structured error handling */
18namespace Mcro::Error
19{
20 using namespace Mcro::Concepts;
21
22 class IError;
23 class SErrorDisplay;
24
25 using IErrorRef = TSharedRef<IError>; /**< Convenience alias for an instance of an error */
26 using IErrorPtr = TSharedPtr<IError>; /**< Convenience alias for an instance of an error */
27 using IErrorWeakPtr = TWeakPtr<IError>; /**< Convenience alias for an instance of an error */
28
29 using FNamedError = TPair<FString, IErrorRef>;
30
31 /** Concept constraining input type argument T to an IError */
32 template <typename T>
33 concept CError = CDerivedFrom<T, IError>;
34
35 /** Concept constraining input type argument T to be an IErrorRef */
36 template <typename T>
37 concept CErrorRef = CSharedRef<T> && CError<typename T::ElementType>;
38
39 /** Concept constraining input type argument T to be an IErrorPtr */
40 template <typename T>
41 concept CErrorPtr = CSharedPtr<T> && CError<typename T::ElementType>;
42
43 /** Concept constraining input type argument T to be an IErrorPtr */
44 template <typename T>
46
47 /** Concept constraining input type argument T to be an IErrorPtr */
48 template <typename T>
50
51 /** Indicate the severity of an error and at what discretion the caller may treat it. */
52 enum class EErrorSeverity
53 {
54 /** Indicates that an inner error just contains extra context for a real error */
55 ErrorComponent = -1,
56
57 /** The caller can handle the error and may continue execution, for example errors with telemetry. */
59
60 /**
61 * A sub-program (like PIE) or a thread should abort its entire purpose but it should not crash the entire
62 * encompassing application, for example early runtime checks about the correctness of some required configuration.
63 */
64 Fatal,
65
66 /**
67 * The application has arrived to an invalid state from which recovery is impossible, for example access
68 * violation errors.
69 */
71 };
72}
TSharedRef< IError > IErrorRef
Definition Error.Fwd.h:25
TWeakPtr< IError > IErrorWeakPtr
Definition Error.Fwd.h:27
TPair< FString, IErrorRef > FNamedError
Definition Error.Fwd.h:29
TSharedPtr< IError > IErrorPtr
Definition Error.Fwd.h:26