MCPcopy Create free account
hub / github.com/Snapchat/Valdi / Error

Class Error

valdi_core/src/valdi_core/cpp/Utils/Error.hpp:28–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26};
27
28class Error {
29public:
30 Error();
31 explicit Error(StringBox message);
32 explicit Error(const std::string_view& message);
33 explicit Error(const char* message);
34 Error(StringBox message, StringBox stackTrace, const Error* cause);
35 Error(StringBox message, int32_t errorCode);
36 Error(Ref<ErrorStorage> storage);
37
38 bool isEmpty() const;
39 bool hasStack() const;
40
41 std::string toString() const;
42 StringBox toStringBox() const;
43
44 /**
45 Return the outer message in the Error hierarchy.
46 */
47 const StringBox& getMessage() const noexcept;
48
49 /**
50 Return the outer stack in the Error hierarchy.
51 */
52 const StringBox& getStack() const noexcept;
53
54 std::optional<Error> getCause() const noexcept;
55
56 /**
57 Return the error code associated with this error.
58 Returns 0 if no specific error code was set.
59 */
60 int32_t getErrorCode() const noexcept;
61
62 bool operator==(const Error& other) const noexcept;
63 bool operator!=(const Error& other) const noexcept;
64
65 Error rethrow(const StringBox& message) const;
66 Error rethrow(std::string_view message) const;
67 Error rethrow(const Error& error) const;
68
69 /**
70 Return an error message that contains a merged message from all the causes, and contains the first resolved stack
71 */
72 Error flatten() const;
73
74 size_t hash() const;
75
76 const Ref<ErrorStorage>& getStorage() const;
77
78private:
79 Ref<ErrorStorage> _storage;
80
81 std::string toString(bool includeCauses) const;
82};
83
84std::ostream& operator<<(std::ostream& os, const Error& error);
85

Callers 15

consumeAndAdvanceMethod · 0.70
Error.cppFile · 0.70
getCauseMethod · 0.70
rethrowMethod · 0.70
flattenMethod · 0.70
onErrorMethod · 0.70
getErrorMethod · 0.70
makeParseErrorMethod · 0.70
doCallMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected