Skip to content

Commit

Permalink
Merge pull request #2365 from GovAlta/script-execution-try-catch
Browse files Browse the repository at this point in the history
don't try to try catch errors
  • Loading branch information
jonathanweyermann authored Dec 7, 2023
2 parents b05eaf6 + 363b7ca commit 448c294
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions apps/script-service/Services/ScriptFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using Adsp.Platform.ScriptService.Services.Platform;
using Adsp.Platform.ScriptService.Events;

using Adsp.Platform.ScriptService.Services.Util;
using Adsp.Sdk;
using NLua;
using RestSharp;
using System.Net.Mime;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Adsp.Platform.ScriptService.Services;
internal class ScriptFunctions : IScriptFunctions
Expand Down Expand Up @@ -111,37 +108,19 @@ public ScriptFunctions(AdspId tenantId, IServiceDirectory directory, Func<Task<s
request.AddJsonBody(body);
request.AddHeader("Authorization", $"Bearer {token}");

var result = new RestResponse();
try
{
result = _client.PostAsync(request).Result;

return "success";

}
catch (AggregateException e)
{
return $"Failure: {e.Message}";
}
var result = _client.PostAsync(request).Result;
return result.Content;
}


public virtual object? HttpGet(string url)
{

var token = _getToken().Result;
var request = new RestRequest(url, Method.Get);
request.AddHeader("Authorization", $"Bearer {token}");

try
{
var response = _client.GetAsync<IDictionary<string, object>>(request).Result;
return response;
}
catch (AggregateException e)
{
return $"Failure: {e.Message}";
}
var response = _client.GetAsync<IDictionary<string, object>>(request).Result;
return response;
}

public virtual string? CreateTask(
Expand Down

0 comments on commit 448c294

Please sign in to comment.