29 #ifndef AGS_SHARED_UTIL_ERROR_H 30 #define AGS_SHARED_UTIL_ERROR_H 32 #include "common/std/memory.h" 33 #include "ags/shared/util/string.h" 48 Error(
int code,
String general, PError inner_error = PError()) : _code(code), _general(general), _innerError(inner_error) {
50 Error(
int code,
String general,
String comment, PError inner_error = PError()) : _code(code), _general(general), _comment(comment), _innerError(inner_error) {
52 Error(
String general, PError inner_error = PError()) : _code(0), _general(general), _innerError(inner_error) {
54 Error(
String general,
String comment, PError inner_error = PError()) : _code(0), _general(general), _comment(comment), _innerError(inner_error) {
71 PError InnerError()
const {
77 String FullMessage()
const {
79 const Error *err =
this;
81 msg.Append(err->General());
82 if (!err->Comment().IsEmpty()) {
84 msg.Append(err->Comment());
86 err = err->InnerError().
get();
122 bool HasError()
const {
123 return _error.get() != NULL;
125 explicit operator bool()
const {
126 return _error.get() ==
nullptr;
128 operator PError()
const {
131 T *operator ->()
const {
132 return _error.operator->();
134 T &operator *()
const {
135 return _error.operator * ();
152 template <
typename CodeType, String(*GetErrorText)(CodeType)>
155 TypedCodeError(CodeType code, PError inner_error = PError()) :
Error(code, GetErrorText(code), inner_error) {
158 Error(code, GetErrorText(code), comment, inner_error) {
161 CodeType Code()
const {
162 return (CodeType)Error::Code();
Definition: achievements_tables.h:27
PointerType get() const
Definition: ptr.h:229