Skip to content

Commit

Permalink
Merge pull request #389 from decadentpig/4.x
Browse files Browse the repository at this point in the history
#364 Provide user-friendly error codes for Firestore tasks
  • Loading branch information
WolfgangSenff authored Mar 26, 2024
2 parents b8e9328 + 4f3852f commit 33173d9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion addons/godot-firebase/firestore/firestore_task.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -114,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))
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:
Expand Down

0 comments on commit 33173d9

Please sign in to comment.