Skip to content

Commit 0712236

Browse files
Merge pull request #434 from syntaxerror247/storage_error_reporting
Fix storage error handling
2 parents 49e6a6f + c89725e commit 0712236

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

addons/godot-firebase/storage/storage.gd

+8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func _check_emulating() -> void :
156156

157157
func _upload(data : PackedByteArray, headers : PackedStringArray, ref : StorageReference, meta_only : bool) -> Variant:
158158
if _is_invalid_authentication():
159+
Firebase._printerr("Error uploading to storage: Invalid authentication")
159160
return 0
160161

161162
var task := StorageTask.new()
@@ -169,6 +170,7 @@ func _upload(data : PackedByteArray, headers : PackedStringArray, ref : StorageR
169170

170171
func _download(ref : StorageReference, meta_only : bool, url_only : bool) -> Variant:
171172
if _is_invalid_authentication():
173+
Firebase._printerr("Error downloading from storage: Invalid authentication")
172174
return 0
173175

174176
var info_task := StorageTask.new()
@@ -204,6 +206,7 @@ func _download(ref : StorageReference, meta_only : bool, url_only : bool) -> Var
204206

205207
func _list(ref : StorageReference, list_all : bool) -> Array:
206208
if _is_invalid_authentication():
209+
Firebase._printerr("Error getting object list from storage: Invalid authentication")
207210
return []
208211

209212
var task := StorageTask.new()
@@ -215,6 +218,7 @@ func _list(ref : StorageReference, list_all : bool) -> Array:
215218

216219
func _delete(ref : StorageReference) -> bool:
217220
if _is_invalid_authentication():
221+
Firebase._printerr("Error deleting object from storage: Invalid authentication")
218222
return false
219223

220224
var task := StorageTask.new()
@@ -270,6 +274,8 @@ func _finish_request(result : int) -> void:
270274

271275
StorageTask.Task.TASK_DOWNLOAD_URL:
272276
var json = Utilities.get_json_data(_response_data)
277+
if json != null and json.has("error"):
278+
Firebase._printerr("Error getting object download url: "+json["error"].message)
273279
if json != null and json.has("downloadTokens"):
274280
task.data = _base_url + _get_file_url(task.ref) + "?alt=media&token=" + json.downloadTokens
275281
else:
@@ -278,6 +284,8 @@ func _finish_request(result : int) -> void:
278284
StorageTask.Task.TASK_LIST, StorageTask.Task.TASK_LIST_ALL:
279285
var json = Utilities.get_json_data(_response_data)
280286
var items := []
287+
if json != null and json.has("error"):
288+
Firebase._printerr("Error getting data from storage: "+json["error"].message)
281289
if json != null and json.has("items"):
282290
for item in json.items:
283291
var item_name : String = item.name

0 commit comments

Comments
 (0)