Skip to content

Commit

Permalink
Merge pull request #24 from OUCC/#6-エラーハンドリング
Browse files Browse the repository at this point in the history
SendAsync内でtry-catchするように変更
  • Loading branch information
Mizuhane authored Jun 24, 2023
2 parents 3134697 + 3d0dff1 commit 398ec5f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Assets/Scripts/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,23 @@ public async UniTask SendAsync()
{
using (request)
{
await request.SendWebRequest();

if (request.result != UnityWebRequest.Result.Success)
try
{
Error = "[ChatGPTConnection] " + request.error + "\n\n" + request.downloadHandler.text;

await request.SendWebRequest();

if (request.result != UnityWebRequest.Result.Success)
{
Error = "[ChatGPTConnection] " + request.error + "\n\n" + request.downloadHandler.text;
}
else
{
Response = JsonConvert.DeserializeObject<ChatGPTDatas.ResponseData>(request.downloadHandler.text);
}
}
else
catch (Exception ex)
{
Response = JsonConvert.DeserializeObject<ChatGPTDatas.ResponseData>(request.downloadHandler.text);
Error = ex.ToString();
}
}
}
Expand Down

0 comments on commit 398ec5f

Please sign in to comment.