forked from gfwilliams/tiny-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptException.h
57 lines (43 loc) · 1.09 KB
/
ScriptException.h
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
51
52
53
54
55
56
/*
* File: ScriptException.h
* Author: ghernan
*
* Exception class to manage script errors.
*
* Created on March 1, 2017, 8:27 PM
*/
#ifndef SCRIPTEXCEPTION_H
#define SCRIPTEXCEPTION_H
#pragma once
#include "ScriptPosition.h"
#include <stdexcept>
#include <string>
/**
* Exceptions throw in script execution / parsing
*/
class CScriptException : public std::logic_error
{
public:
CScriptException(const std::string &text, const ScriptPosition& pos) :
logic_error(text), Position(pos)
{
}
const ScriptPosition Position;
};
/**
* Class for exceptions which may occur executing the script.
*/
class RuntimeError : public std::logic_error
{
public:
RuntimeError (const std::string& text, const VmPosition& pos)
: logic_error(text), Position(pos)
{
}
const VmPosition Position;
};
//Exception helper functions
void rtError(const char* msgFormat, ...);
void errorAt(const ScriptPosition& position, const char* msgFormat, ...);
void errorAt_v(const ScriptPosition& position, const char* msgFormat, va_list args);
#endif /* SCRIPTEXCEPTION_H */