Skip to content

Commit af760df

Browse files
update HTTP method errors
1 parent 4820da6 commit af760df

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Code/MethodSystem/Methods/HTTPMethods/HTTPGetMethod.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ public override IEnumerator<float> Execute()
3838
using UnityWebRequest webRequest = UnityWebRequest.Get(address);
3939

4040
yield return Timing.WaitUntilDone(webRequest.SendWebRequest());
41-
42-
if (webRequest.result != UnityWebRequest.Result.Success)
41+
42+
if (webRequest.error is { } error)
4343
{
44-
throw new ScriptRuntimeError(
45-
this,
46-
$"Address {address} has returned {webRequest.result} ({webRequest.responseCode}): {webRequest.error}"
44+
throw new ScriptRuntimeError(this,
45+
$"Address {address} has returned an error: {error}"
4746
);
4847
}
4948

Code/MethodSystem/Methods/HTTPMethods/HTTPPostMethod.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ public static IEnumerator<float> SendPost(Method caller, string url, string json
5050
request.SetRequestHeader("Content-Type", "application/json");
5151

5252
yield return Timing.WaitUntilDone(request.SendWebRequest());
53-
54-
Log.Signal($"{request.error} error");
55-
if (request.result != UnityWebRequest.Result.Success)
53+
54+
if (request.error is { } error)
5655
{
5756
throw new ScriptRuntimeError(
58-
caller,
59-
$"Address {url} has returned {request.result} ({request.responseCode}): {request.error}"
57+
caller,
58+
$"Address {url} has returned an error: {error}"
6059
);
6160
}
6261
}

0 commit comments

Comments
 (0)