Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #25, limit the number of characters returned to 5120 characters

  • Loading branch information...
commit 77985ae94e6c269912e156d739626da787296471 1 parent c5aeb7a
@jrusbatch authored
Showing with 15 additions and 13 deletions.
  1. +12 −12 Core/Services/CodeExecuter.cs
  2. +3 −1 Worker/Program.cs
View
24 Core/Services/CodeExecuter.cs
@@ -88,17 +88,17 @@ public object Execute(string code)
var timeout = TimeSpan.FromSeconds(5);
try
{
- var task = Task.Factory.StartNew(() =>
- {
- try
- {
- result = loader.Run("EntryPoint", "Result", compiledAssembly);
- }
- catch (Exception ex) {
- var inner = ex.InnerException;
- result = ex.InnerException != null ? inner.Message : ex.Message;
- }
- }, TaskCreationOptions.PreferFairness);
+ var task = Task.Factory
+ .StartNew(() =>
+ {
+ try
+ {
+ result = loader.Run("EntryPoint", "Result", compiledAssembly);
+ }
+ catch (Exception ex) {
+ result = ex.InnerException ?? ex;
+ }
+ });
if (!task.Wait(timeout))
{
@@ -109,7 +109,7 @@ public object Execute(string code)
}
catch (Exception ex)
{
- result = ex.Message;
+ result = ex.InnerException ?? ex;
}
if (!unloaded)
View
4 Worker/Program.cs
@@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Compilify.Services;
using Newtonsoft.Json;
+using Roslyn.Scripting.CSharp;
using ServiceStack.Redis;
using NLog;
@@ -106,9 +107,10 @@ private static void OnTaskFaulted(Task task)
Logger.Info("Executed: {0}", command.Code ?? string.Empty);
+ var formatter = new ObjectFormatter(maxLineLength: 5120);
var response = JsonConvert.SerializeObject(new {
code = command.Code,
- result = result,
+ result = formatter.FormatObject(result),
time = DateTime.UtcNow,
duration = stopWatch.ElapsedMilliseconds
});
Please sign in to comment.
Something went wrong with that request. Please try again.