From ac13f34e5a43c31f447b0ef0907461ebf15d4cd3 Mon Sep 17 00:00:00 2001 From: Marlo-Ong Date: Tue, 14 May 2024 20:22:39 -0700 Subject: [PATCH] Separate user error from debug error messages in popup --- Assets/Scripts/ChatResponseSerializer.cs | 4 ++-- Assets/Scripts/StateMachine.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/ChatResponseSerializer.cs b/Assets/Scripts/ChatResponseSerializer.cs index 2a1fb31..fc9dd72 100644 --- a/Assets/Scripts/ChatResponseSerializer.cs +++ b/Assets/Scripts/ChatResponseSerializer.cs @@ -138,7 +138,7 @@ private bool SerializeChatResponse(string response) catch (Exception err) { - StateMachine.Instance.ThrowError("Serialization of ChatGPT response failed - please try again", State.MainMenu); + StateMachine.Instance.ThrowError(err.Message, "Serialization of ChatGPT response failed - please try again", State.MainMenu); return false; } } @@ -162,7 +162,7 @@ private Question JSONifyQuestion(GameQuestion q) catch (Exception err) { - StateMachine.Instance.ThrowError(err.Message); + Debug.Log(err.Message); // non-essential error } return null; diff --git a/Assets/Scripts/StateMachine.cs b/Assets/Scripts/StateMachine.cs index 7118d1a..7009a5b 100644 --- a/Assets/Scripts/StateMachine.cs +++ b/Assets/Scripts/StateMachine.cs @@ -101,11 +101,11 @@ private void StateExit(State state) # endregion - public void ThrowError(string err, State revertState = State.None) + public void ThrowError(string err, string userErr = null, State revertState = State.None) { Debug.LogError(err); Canvas_ErrorMessage.SetActive(true); - Canvas_ErrorMessage.GetComponentInChildren().text = err; + Canvas_ErrorMessage.GetComponentInChildren().text = userErr ?? err; if (revertState != State.None) { ChangeToState(revertState);