greybel-interpreter 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cps.js CHANGED
@@ -83,12 +83,12 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
83
83
  const importExpr = item;
84
84
  const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.path);
85
85
  if (stack.includes(target)) {
86
- console.warn('Found circluar dependency. Using noop operation.');
86
+ console.warn(`Found circluar dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
87
87
  return new noop_1.Noop(item, target);
88
88
  }
89
89
  const code = yield context.handler.resourceHandler.get(target);
90
90
  if (code == null) {
91
- throw new error_1.PrepareError(`Cannot find import ${currentTarget}.`, {
91
+ throw new error_1.PrepareError(`Cannot find import "${currentTarget}" at line ${item.start.line}.`, {
92
92
  target: currentTarget,
93
93
  item
94
94
  });
@@ -99,22 +99,25 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
99
99
  return importStatement;
100
100
  }
101
101
  catch (err) {
102
+ if (err instanceof error_1.PrepareError) {
103
+ throw err;
104
+ }
102
105
  throw new error_1.PrepareError(err.message, {
103
- target: currentTarget,
106
+ target,
104
107
  item
105
- });
108
+ }, err);
106
109
  }
107
110
  }
108
111
  case greybel_core_1.ASTType.FeatureIncludeExpression: {
109
112
  const includeExpr = item;
110
113
  const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, includeExpr.path);
111
114
  if (stack.includes(target)) {
112
- console.warn('Found circluar dependency. Using noop operation.');
115
+ console.warn(`Found circluar dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
113
116
  return new noop_1.Noop(item, target);
114
117
  }
115
118
  const code = yield context.handler.resourceHandler.get(target);
116
119
  if (code == null) {
117
- throw new error_1.PrepareError(`Cannot find include ${currentTarget}.`, {
120
+ throw new error_1.PrepareError(`Cannot find include "${currentTarget}" at line ${item.start.line}.`, {
118
121
  target: currentTarget,
119
122
  item
120
123
  });
@@ -125,26 +128,29 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
125
128
  return importStatement;
126
129
  }
127
130
  catch (err) {
131
+ if (err instanceof error_1.PrepareError) {
132
+ throw err;
133
+ }
128
134
  throw new error_1.PrepareError(err.message, {
129
- target: currentTarget,
135
+ target,
130
136
  item
131
- });
137
+ }, err);
132
138
  }
133
139
  }
134
140
  case greyscript_core_1.ASTType.ImportCodeExpression: {
135
141
  const importExpr = item;
136
142
  if (importExpr.fileSystemDirectory === null) {
137
- console.warn(`Ignoring dependency in ${currentTarget}. Using noop operation.`);
143
+ console.warn(`Ignoring dependency "${importExpr.gameDirectory}" in "${currentTarget}" at line "${item.start.line}" due to missing file system path. Using noop operation.`);
138
144
  return new noop_1.Noop(item, currentTarget);
139
145
  }
140
146
  const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.fileSystemDirectory);
141
147
  if (stack.includes(target)) {
142
- console.warn(`Found circluar dependency in ${currentTarget}. Using noop operation.`);
148
+ console.warn(`Found circluar dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
143
149
  return new noop_1.Noop(item, target);
144
150
  }
145
151
  const code = yield context.handler.resourceHandler.get(target);
146
152
  if (code == null) {
147
- throw new error_1.PrepareError(`Cannot find native import ${currentTarget}.`, {
153
+ throw new error_1.PrepareError(`Cannot find native import "${currentTarget}" at line ${item.start.line}.`, {
148
154
  target: currentTarget,
149
155
  item
150
156
  });
@@ -155,10 +161,13 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
155
161
  return importStatement;
156
162
  }
157
163
  catch (err) {
164
+ if (err instanceof error_1.PrepareError) {
165
+ throw err;
166
+ }
158
167
  throw new error_1.PrepareError(err.message, {
159
- target: currentTarget,
168
+ target,
160
169
  item
161
- });
170
+ }, err);
162
171
  }
163
172
  }
164
173
  case greybel_core_1.ASTType.FeatureDebuggerExpression:
@@ -113,11 +113,11 @@ class Interpreter extends events_1.EventEmitter {
113
113
  yield top.handle(injectionCtx);
114
114
  }
115
115
  catch (err) {
116
- if (err instanceof error_1.PrepareError) {
116
+ if (err instanceof error_1.PrepareError || err instanceof error_1.RuntimeError) {
117
117
  this.handler.errorHandler.raise(err);
118
118
  }
119
119
  else {
120
- this.handler.errorHandler.raise(new error_1.RuntimeError(err.message, this.apiContext.getLastActive()));
120
+ this.handler.errorHandler.raise(new error_1.RuntimeError(err.message, this.apiContext.getLastActive(), err));
121
121
  }
122
122
  }
123
123
  return this;
@@ -163,11 +163,11 @@ class Interpreter extends events_1.EventEmitter {
163
163
  yield process;
164
164
  }
165
165
  catch (err) {
166
- if (err instanceof error_1.PrepareError) {
166
+ if (err instanceof error_1.PrepareError || err instanceof error_1.RuntimeError) {
167
167
  this.handler.errorHandler.raise(err);
168
168
  }
169
169
  else {
170
- this.handler.errorHandler.raise(new error_1.RuntimeError(err.message, this.apiContext.getLastActive()));
170
+ this.handler.errorHandler.raise(new error_1.RuntimeError(err.message, this.apiContext.getLastActive(), err));
171
171
  }
172
172
  }
173
173
  finally {
@@ -194,7 +194,12 @@ class Interpreter extends events_1.EventEmitter {
194
194
  return this.apiContext.exit();
195
195
  }
196
196
  catch (err) {
197
- this.handler.errorHandler.raise(err);
197
+ if (err instanceof error_1.PrepareError || err instanceof error_1.RuntimeError) {
198
+ this.handler.errorHandler.raise(err);
199
+ }
200
+ else {
201
+ this.handler.errorHandler.raise(new error_1.RuntimeError(err.message, this.apiContext.getLastActive(), err));
202
+ }
198
203
  }
199
204
  }
200
205
  setGlobalVariable(path, value) {
@@ -8,7 +8,8 @@ export declare class RuntimeError extends Error {
8
8
  relatedItem: ASTBase | null;
9
9
  relatedTarget: string;
10
10
  stackTrace: Set<ASTBase>;
11
- constructor(message: string, context: RuntimeContext);
11
+ source?: Error;
12
+ constructor(message: string, context: RuntimeContext, source?: Error);
12
13
  private createTrace;
13
14
  }
14
15
  interface PrepareContext {
@@ -18,6 +19,7 @@ interface PrepareContext {
18
19
  export declare class PrepareError extends Error {
19
20
  relatedItem: ASTBase | null;
20
21
  relatedTarget: string;
21
- constructor(message: string, context: PrepareContext);
22
+ source?: Error;
23
+ constructor(message: string, context: PrepareContext, source?: Error);
22
24
  }
23
25
  export {};
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PrepareError = exports.RuntimeError = void 0;
4
4
  class RuntimeError extends Error {
5
- constructor(message, context) {
5
+ constructor(message, context, source) {
6
6
  super(message);
7
7
  this.relatedItem = context.stackItem || null;
8
8
  this.relatedTarget = context.target;
9
9
  this.stackTrace = this.createTrace(context);
10
+ this.source = source;
10
11
  }
11
12
  createTrace(context) {
12
13
  const result = new Set();
@@ -20,10 +21,11 @@ class RuntimeError extends Error {
20
21
  }
21
22
  exports.RuntimeError = RuntimeError;
22
23
  class PrepareError extends Error {
23
- constructor(message, context) {
24
+ constructor(message, context, source) {
24
25
  super(message);
25
26
  this.relatedItem = context.item;
26
27
  this.relatedTarget = context.target;
28
+ this.source = source;
27
29
  }
28
30
  }
29
31
  exports.PrepareError = PrepareError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",