-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcc_error.cpp
More file actions
76 lines (66 loc) · 2.05 KB
/
Copy pathcc_error.cpp
File metadata and controls
76 lines (66 loc) · 2.05 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//=============================================================================
//
// Adventure Game Studio (AGS)
//
// Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
// The full list of copyright holders can be found in the Copyright.txt
// file, which is part of this source code distribution.
//
// The AGS source code is provided under the Artistic License 2.0.
// A copy of this license can be found in the file License.txt and at
// http://www.opensource.org/licenses/artistic-license-2.0.php
//
//=============================================================================
#include <stdio.h>
#include <utility>
#include <iostream>
#include "script_common.h" // current_line
#include "util_string.h"
using namespace AGS::Common;
// Returns full script error message and callstack (if possible)
extern std::pair<String, String> cc_error_at_line(const char *error_msg);
// Returns script error message without location or callstack
extern String cc_error_without_line(const char *error_msg);
int ccPrintAllErrors = 0;
int ccError = 0;
int ccErrorLine = 0;
String ccErrorString;
String ccErrorCallStack;
bool ccErrorIsUserError = false;
const char *ccCurScriptName = "";
void cc_error(const char *descr, ...)
{
ccErrorIsUserError = false;
if (descr[0] == '!')
{
ccErrorIsUserError = true;
descr++;
}
char displbuf[1000];
va_list ap;
va_start(ap, descr);
vsprintf(displbuf, descr, ap);
va_end(ap);
if (currentline > 0)
{
// [IKM] Implementation is project-specific
std::pair<String, String> errinfo = cc_error_at_line(displbuf);
ccErrorString = errinfo.first;
ccErrorCallStack = errinfo.second;
}
else
{
ccErrorString = cc_error_without_line(displbuf);
ccErrorCallStack = "";
}
if(ccPrintAllErrors) {
std::cout << ccErrorString;
std::cout << std::endl;
if(ccErrorCallStack != "") {
std::cout << ccErrorCallStack;
std::cout << std::endl;
}
}
ccError = 1;
ccErrorLine = currentline;
}