Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ocalles committed May 21, 2024
1 parent 247aba5 commit 7503d71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Microsoft.TryDotNet.WasmRunner/CodeRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public async Task<RunResults> RunAssemblyEntryPoint(Assembly assembly, Action<st
}
catch (Exception e)
{
onOutput(e.ToString());
switch (e.InnerException)
{
case TypeLoadException:
Expand Down
18 changes: 13 additions & 5 deletions src/Microsoft.TryDotNet.WasmRunner/CodeRunnerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ public CodeRunnerAdapter(CodeRunner runner, IJSRuntime jsInterop)
[JSInvokable]
public async Task<SerializableCodeRunnerResult> RunAssembly(string base64EncodedAssembly)
{
var result = await _runner.RunAssemblyEntryPoint(base64EncodedAssembly,
output => _jsInterop.InvokeAsync<object>("publishCodeRunnerStdOut", output),
error => _jsInterop.InvokeAsync<object>("publishCodeRunnerStdError", error)
);
try
{
var result = await _runner.RunAssemblyEntryPoint(base64EncodedAssembly,
output => _jsInterop.InvokeAsync<object>("publishCodeRunnerStdOut", output),
error => _jsInterop.InvokeAsync<object>("publishCodeRunnerStdError", error)
);

return new SerializableCodeRunnerResult(result.Succeeded, result.Exception?.Message, result.RunnerException?.Message);
return new SerializableCodeRunnerResult(result.Succeeded, result.Exception?.Message, result.RunnerException?.Message);
}
catch(Exception ex)
{
await _jsInterop.InvokeAsync<object>("publishCodeRunnerStdError", ex.Message);
return new SerializableCodeRunnerResult(false, ex.Message, null);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/microsoft-trydotnet-editor/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class WasmRunner {
switch (type) {
case "wasmRunner-result":
polyglotNotebooks.Logger.default.info("WasmRunner execution completed");
if (wasmRunnerMessage.result && !wasmRunnerMessage.result.success) {
runRequest.onOutput(wasmRunnerMessage.result.error || wasmRunnerMessage.result.runnerError);
}
completionSource.resolve(wasmRunnerMessage);
break;
case "wasmRunner-stdout":
Expand Down

0 comments on commit 7503d71

Please sign in to comment.