MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / GCodeException

Class GCodeException

src/GCodes/GCodeException.h:32–78  ·  view source on GitHub ↗

This class is mostly used to throw exceptions when processing GCode. It is also used to store error messages that need to be retrieved later. Field "message" should always point to a constant string in flash memory, or be null. The error message may have a string, int32_t or uint32_t parameter

Source from the content-addressed store, hash-verified

30// Field "message" should always point to a constant string in flash memory, or be null.
31// The error message may have a string, int32_t or uint32_t parameter
32class GCodeException
33{
34public:
35 GCodeException() noexcept : line(-1), column(-1), message(nullptr), source(GCodeExceptionSource::other) { }
36 explicit GCodeException(const char *_ecv_array msg, int32_t iparam = 0) noexcept: line(-1), column(-1), message(msg), source(GCodeExceptionSource::other) { param.i = iparam; }
37
38 GCodeException(int lin, int col, const char *_ecv_array msg) noexcept : line(lin), column(col), message(msg), source(GCodeExceptionSource::other) { }
39
40 GCodeException(int lin, int col, const char *_ecv_array msg, const char *_ecv_array sparam) noexcept : line(lin), column(col), message(msg), source(GCodeExceptionSource::other)
41 {
42 stringParam.copy(sparam);
43 }
44
45 GCodeException(int lin, int col, const char *_ecv_array msg, uint32_t uparam) noexcept : line(lin), column(col), message(msg), source(GCodeExceptionSource::other)
46 {
47 param.u = uparam;
48 }
49
50 GCodeException(int lin, int col, const char *_ecv_array msg, int32_t iparam) noexcept : line(lin), column(col), message(msg), source(GCodeExceptionSource::other)
51 {
52 param.i = iparam;
53 }
54
55 GCodeException(const GCodeBuffer *null gb, int col, const char *_ecv_array msg) noexcept;
56
57 GCodeException(const GCodeBuffer *null gb, int col, const char *_ecv_array msg, uint32_t uparam) noexcept;
58
59 GCodeException(const GCodeBuffer *null gb, int col, const char *_ecv_array msg, const char *_ecv_array sparam) noexcept;
60
61 void GetMessage(const StringRef& reply, const GCodeBuffer *null gb) const noexcept;
62
63 void DebugPrint() const noexcept;
64
65 bool IsNull() const noexcept { return message == nullptr; }
66
67private:
68 int line;
69 int column;
70 const char *_ecv_array _ecv_null message;
71 GCodeExceptionSource source;
72 union
73 {
74 int32_t i;
75 uint32_t u;
76 } param;
77 String<StringLength50> stringParam;
78};
79
80// Functions to create and throw an exception. Using these avoids allocating the GCodeException object on the local stack when it is not going to be used.
81[[noreturn]] void __attribute__((noinline)) ThrowGCodeException(const char *_ecv_array errMsg) THROWS(GCodeException);

Callers 15

THROWSFunction · 0.70
SetErrorMethod · 0.70
SetWarningMethod · 0.70
SetStateMethod · 0.70
THROWSFunction · 0.70
THROWSFunction · 0.50
THROWSFunction · 0.50
THROWSFunction · 0.50
THROWSFunction · 0.50
THROWSFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected