Skip to content

Commit ad633d5

Browse files
committed
[js] Implement nqp::backtracestrings.
For now returns the raw js LTA backtrace.
1 parent 38c8d8e commit ad633d5

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/vm/js/nqp-runtime/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ op.getstaticcode = function(codeRef) {
974974
};
975975

976976
op.backtracestrings = function(exception) {
977-
return new NQPArray(['backtrace NYI']);
977+
return new NQPArray([exception.stack.replace(/^Error: .*\n/, '')]);
978978
};
979979

980980
op.hintfor = function(classHandle, attrName) {

src/vm/js/nqp-runtime/ctx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Ctx extends NQPObject {
3434
}
3535
ctx = ctx.$$caller;
3636
}
37-
throw exception.message;
37+
throw exception;
3838
}
3939

4040
catchException(exception) {
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
function NQPException(message) {
2-
this.name = 'NQPException';
3-
this.message = message;
4-
}
1+
class NQPException extends Error {
2+
constructor(message) {
3+
super(message);
4+
}
55

6-
NQPException.prototype = Object.create(Error.prototype);
7-
NQPException.prototype.constructor = NQPException;
6+
Str(ctx, _NAMED, self) {
7+
return this.message;
8+
}
89

9-
NQPException.prototype.Str = function(ctx, _NAMED, self) {
10-
return this.message;
11-
};
12-
13-
NQPException.prototype.$$toBool = function(ctx) {
14-
return 1;
15-
};
10+
$$toBool(ctx) {
11+
return 1;
12+
}
1613

17-
NQPException.prototype.$$decont = function(ctx) {
18-
return this;
14+
$$decont(ctx) {
15+
return this;
16+
}
1917
};
2018

2119
module.exports = NQPException;

0 commit comments

Comments
 (0)