Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Apr 19, 2024
1 parent 73d0e0b commit 56ad9d9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/HLAdapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class HLAdapter extends DebugSession {

function error<T>(response:Response<T>, message:Dynamic) {
sendErrorResponse(cast response, 3000, "" + message);
sendToOutput("ERROR : " + message, OutputEventCategory.Stderr);
errorMessage("ERROR : " + message);
}

/**
Expand Down Expand Up @@ -318,9 +318,11 @@ class HLAdapter extends DebugSession {
}
var api = new hld.NodeDebugApiNative(pid, dbg.is64);
if( !dbg.init(api) ) {
onError("Failed to initialize debugger");
var msg = "Failed to initialize debugger";
if( Sys.systemName() == "Linux" )
trace("On Linux, please try set /proc/sys/kernel/yama/ptrace_scope to 0");
msg += ". On Linux, please try set /proc/sys/kernel/yama/ptrace_scope to 0.";
onError(msg);
return;
return;
}
dbg.eval.allowEvalGetters = allowEvalGetters;
Expand Down Expand Up @@ -614,15 +616,15 @@ class HLAdapter extends DebugSession {
namedVariables : fields.length,
});
} catch( e : Dynamic ) {
trace(e);
errorMessage(e);
}
}
var cl = dbg.getCurrentClass();
if( cl != null ) {
try {
var fields = dbg.getClassStatics(cl);
for( f in fields.copy() ) {
var v = try dbg.getValue(cl+"."+f, true) catch( e : Dynamic ) { trace(e+" ("+cl+"."+f+")"); continue; };
var v = try dbg.getValue(cl+"."+f, true) catch( e : Dynamic ) { errorMessage(e+" ("+cl+"."+f+")"); continue; };
if( v == null || v.t.match(HFun(_)) )
fields.remove(f);
}
Expand All @@ -634,7 +636,7 @@ class HLAdapter extends DebugSession {
namedVariables : fields.length,
});
} catch( e : Dynamic ) {
trace(e);
errorMessage(e);
}
}
sendResponse(response);
Expand Down Expand Up @@ -1070,10 +1072,6 @@ class HLAdapter extends DebugSession {
return null;
}

function sendToOutput(output:String, category:OutputEventCategory = Console) {
sendEvent(new OutputEvent(output + "\n", category));
}

function errorMessage( msg : String ) {
sendEvent(new OutputEvent(msg+"\n", Stderr));
}
Expand Down

0 comments on commit 56ad9d9

Please sign in to comment.