MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
ErrorManager.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/Error.h
"
16
#include "
Mcro/Delegates/EventDelegate.h
"
17
18
namespace
Mcro::Error
19
{
20
/** Global facilities for IError handling, including displaying them to the user, trigger error events, etc */
21
class
MCRO_API
FErrorManager
22
{
23
public
:
24
25
/** Get the global singleton */
26
static
FErrorManager
&
Get
();
27
28
/** The results of displaying an error. In all cases the error is logged. */
29
enum
EDisplayErrorResult
30
{
31
/** The error has been displayed for the user. */
32
Displayed
,
33
34
/** The error has not been shown to the user because another error is already being shown. */
35
Suppressed_AnotherErrorOpen
,
36
37
/** Modal windows couldn't be created at the time, so we couldn't show it to the user either. */
38
Suppressed_CannotDisplayModalWindow
,
39
};
40
41
/** Control how an error is being displayed. Use C++ 20 designated initializers for convenience */
42
struct
FDisplayErrorArgs
43
{
44
/**
45
* The error message will not block the engine tick. This is useful for errors happening in the editor
46
* so even if PIE session is aborted due to an error, the developer can cross-check their assets with the
47
* error still open.
48
*/
49
bool
bAsync =
false
;
50
51
/** Enables an extra checkbox which reminds the user to please do not immediately dismiss the error */
52
bool
bImportantToRead =
false
;
53
54
/**
55
* Optionally set a parent widget for the modal window of the error. By default if not specified here the
56
* main editor window is used, or the main gameplay viewport.
57
*/
58
TSharedPtr<const SWidget> Parent = {};
59
};
60
61
/**
62
* Display the error summary for the user. Only use this when your program arrives to an unrecoverable state
63
* which either needs explanation for the user or requires action from the user (like configuration changes).
64
* The modal window and the widgets representing the error will be created on the main thread, keep that in
65
* mind while making the widgets for the errors.
66
*
67
* @param error The input error
68
* @param args Simple arguments object for this function, use initializer list or C++ 20 designated initializer.
69
*
70
* @return
71
* A future telling that either the dialog has been displayed or how it has been suppressed. The future also
72
* gives an opportunity to block the calling thread until the user acknowledges the error.
73
*
74
* @remarks
75
* Unless `bAsync` is set in the arguments, calling this function from any thread will also block the main
76
* thread while the modal window containing the error is open. If the calling thread also needs to be blocked
77
* then simply wait on the returned future.
78
*
79
* @todo
80
* Add ability to let the user "ignore" errors, and continue execution.
81
*/
82
auto
DisplayError
(
IErrorRef
const
& error,
FDisplayErrorArgs
const
& args) -> TFuture<EDisplayErrorResult>;
83
84
private
:
85
86
auto
DisplayError_MainThread(
IErrorRef
const
& error,
FDisplayErrorArgs
const
& args) ->
EDisplayErrorResult
;
87
auto
InferParentWidget() -> TSharedPtr<const SWidget>;
88
89
FThreadSafeBool bIsDisplayingError;
90
};
91
}
Error.h
EventDelegate.h
Mcro::Error::FErrorManager
Definition
ErrorManager.h:22
Mcro::Error::FErrorManager::Get
static FErrorManager & Get()
Mcro::Error::FErrorManager::EDisplayErrorResult
EDisplayErrorResult
Definition
ErrorManager.h:30
Mcro::Error::FErrorManager::Displayed
@ Displayed
Definition
ErrorManager.h:32
Mcro::Error::FErrorManager::Suppressed_AnotherErrorOpen
@ Suppressed_AnotherErrorOpen
Definition
ErrorManager.h:35
Mcro::Error::FErrorManager::Suppressed_CannotDisplayModalWindow
@ Suppressed_CannotDisplayModalWindow
Definition
ErrorManager.h:38
Mcro::Error::FErrorManager::DisplayError
auto DisplayError(IErrorRef const &error, FDisplayErrorArgs const &args) -> TFuture< EDisplayErrorResult >
Mcro::Error
Definition
Error.Fwd.h:19
Mcro::Error::IErrorRef
TSharedRef< IError > IErrorRef
Definition
Error.Fwd.h:25
Mcro::Error::FErrorManager::FDisplayErrorArgs
Definition
ErrorManager.h:43
Mcro_Origin
Public
Mcro
Error
ErrorManager.h
Generated by
1.12.0