Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GCodeException.h « GCodes « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f11d6e1d59be7bc4a9153aeddd8727dc356c9f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * ParseException.h
 *
 *  Created on: 21 Dec 2019
 *      Author: David
 */

#ifndef SRC_GCODES_GCODEEXCEPTION_H_
#define SRC_GCODES_GCODEEXCEPTION_H_

#include <cstdint>

class StringRef;
class GCodeBuffer;

class GCodeException
{
public:
	GCodeException(int lin, int col, const char *msg) noexcept : line(lin), column(col), message(msg)  { }

	GCodeException(int lin, int col, const char *msg, const char *sparam) noexcept : line(lin), column(col), message(msg)
	{
		param.s = sparam;
	}

	GCodeException(int lin, int col, const char *msg, uint32_t uparam) noexcept : line(lin), column(col), message(msg)
	{
		param.u = uparam;
	}

	GCodeException(int lin, int col, const char *msg, int32_t iparam) noexcept : line(lin), column(col), message(msg)
	{
		param.i = iparam;
	}

	void GetMessage(const StringRef& reply, const GCodeBuffer& gb) const noexcept;

private:
	int line;
	int column;
	const char *message;
	union
	{
		int32_t i;
		uint32_t u;
		const char *s;
	} param;
};

#endif /* SRC_GCODES_GCODEEXCEPTION_H_ */