GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
532 stars 76 forks source link

Fix issue #161 - Firestore .get() issue #162

Closed BearDooks closed 3 years ago

BearDooks commented 3 years ago

This will close #161

There is an issue when you try to use .get() in firestore on a document that does not exist. If you also have collection connected for errors, you will crash the plugin. This is because the error function from firestore_collection is looking for three arguments, but the error function in firestore_task only passes one.

I changed the line to

emit_signal("error", data.code, 0, data.message)

This will satisfy the number of arguments as well as the accepted type. Need to discuss if hard coding a 0 is worth it or if we should use something else.

fenix-hub commented 3 years ago

Firestore API sends a body error with the following arguments

code: int 
message: String
status: String

So no need to hardcode 0

On my current branch I have the following structure

        match action:
            TASK_LIST, TASK_QUERY:
                emit_signal("error", bod[0].error)
                emit_signal("task_finished", bod[0].error)
                data = bod[0].error
            _:
                var code : String = bod.error.code as String
                var status : String = bod.error.status as String
                var message : String = bod.error.message as String
                emit_signal("error", bod.error)
                emit_signal("task_finished", bod.error)
                data = bod.error

Which seems to be working with any error