Skip to content

Commit

Permalink
Merge pull request #244 from lightpanda-io/trycatch-env-not-started
Browse files Browse the repository at this point in the history
try_catch: check if the env is started before get it
  • Loading branch information
krichprollsch authored Jul 19, 2024
2 parents a486251 + 31d4b8c commit ade128f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/engines/v8/v8.zig
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ pub const TryCatch = struct {

// the caller needs to deinit the string returned
pub fn exception(self: TryCatch, alloc: std.mem.Allocator, env: Env) anyerror!?[]const u8 {
if (env.js_ctx == null) return error.EnvNotStarted;

if (self.inner.getException()) |msg| {
return try valueToUtf8(alloc, msg, env.isolate, env.js_ctx.?);
}
Expand All @@ -461,6 +463,8 @@ pub const TryCatch = struct {

// the caller needs to deinit the string returned
pub fn stack(self: TryCatch, alloc: std.mem.Allocator, env: Env) anyerror!?[]const u8 {
if (env.js_ctx == null) return error.EnvNotStarted;

const stck = self.inner.getStackTrace(env.js_ctx.?);
if (stck) |s| return try valueToUtf8(alloc, s, env.isolate, env.js_ctx.?);
return null;
Expand Down

0 comments on commit ade128f

Please sign in to comment.