From 440fae34ff1301066fc222fd4da976599d8533db Mon Sep 17 00:00:00 2001 From: j Date: Tue, 26 Mar 2024 09:09:31 +0000 Subject: [PATCH 1/2] Added user-friendly descriptions of action codes for errors in Firestore Tasks --- addons/godot-firebase/firestore/firestore_task.gd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/godot-firebase/firestore/firestore_task.gd b/addons/godot-firebase/firestore/firestore_task.gd index def0736..7cf7bfa 100644 --- a/addons/godot-firebase/firestore/firestore_task.gd +++ b/addons/godot-firebase/firestore/firestore_task.gd @@ -55,6 +55,16 @@ enum Task { TASK_LIST ## A POST Request Task, processing a list() request } +## Mapping of Task enum values to descriptions for use in printing user-friendly error codes. +const TASK_MAP { + Task.TASK_GET: "GET DOCUMENT", + Task.TASK_POST: "ADD DOCUMENT", + Task.TASK_PATCH: "UPDATE DOCUMENT", + Task.TASK_DELETE: "DELETE DOCUMENT", + Task.TASK_QUERY: "QUERY COLLECTION", + Task.TASK_LIST: "LIST DOCUMENTS" +} + ## The code indicating the request Firestore is processing. ## See @[enum FirebaseFirestore.Requests] to get a full list of codes identifiers. ## @setter set_action @@ -114,7 +124,7 @@ func _on_request_completed(result : int, response_code : int, headers : PackedSt data.append(bod.nextPageToken) listed_documents.emit(data) else: - Firebase._printerr("Action in error was: " + str(action)) + Firebase._printerr("Action in error was: " + str(action) + " (" + TASK_MAP[action] + ")") emit_error(task_error, bod, action) match action: Task.TASK_POST: From 4f3852f84aee9563dc2d879d56fa6fb0182ee028 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 26 Mar 2024 10:23:07 +0000 Subject: [PATCH 2/2] Ensure task description exists in map before printing --- addons/godot-firebase/firestore/firestore_task.gd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/godot-firebase/firestore/firestore_task.gd b/addons/godot-firebase/firestore/firestore_task.gd index 7cf7bfa..32d7e6a 100644 --- a/addons/godot-firebase/firestore/firestore_task.gd +++ b/addons/godot-firebase/firestore/firestore_task.gd @@ -124,7 +124,11 @@ func _on_request_completed(result : int, response_code : int, headers : PackedSt data.append(bod.nextPageToken) listed_documents.emit(data) else: - Firebase._printerr("Action in error was: " + str(action) + " (" + TASK_MAP[action] + ")") + var description = "" + if TASK_MAP.has(action): + description = "(" + TASK_MAP[action] + ")" + + Firebase._printerr("Action in error was: " + str(action) + " " + description) emit_error(task_error, bod, action) match action: Task.TASK_POST: