diff --git a/addons/supabase/Auth/auth_error.gd b/addons/supabase/Auth/auth_error.gd index 5cd547b..dec6111 100644 --- a/addons/supabase/Auth/auth_error.gd +++ b/addons/supabase/Auth/auth_error.gd @@ -5,7 +5,7 @@ class_name SupabaseAuthError func _init(dictionary : Dictionary = {}) -> void: _error = dictionary if not _error.is_empty(): - hint = _error.get("error", "(undefined)") + type = _error.get("error", "(undefined)") hint = _error.get("error_description", "(undefined)") if _error.has("code"): code = str(_error.get("code", -1)) diff --git a/addons/supabase/Auth/auth_task.gd b/addons/supabase/Auth/auth_task.gd index ba4a818..f35d3fd 100644 --- a/addons/supabase/Auth/auth_task.gd +++ b/addons/supabase/Auth/auth_task.gd @@ -33,7 +33,11 @@ func match_code(code: int = Task.NONE) -> int: return HTTPClient.METHOD_GET func _on_task_completed(result : int, response_code : int, headers : PackedStringArray, body : PackedByteArray, handler: HTTPRequest) -> void: - var result_body : Dictionary = JSON.parse_string(body.get_string_from_utf8()) + var result_body : Dictionary + + if(!body.is_empty()): + result_body = JSON.parse_string(body.get_string_from_utf8()) + match response_code: 200: match _code: @@ -46,7 +50,6 @@ func _on_task_completed(result : int, response_code : int, headers : PackedStrin Task.LOGOUT, Task.USER: complete() _: - if result_body == null : result_body = {} complete(null, {}, SupabaseAuthError.new(result_body)) handler.queue_free() diff --git a/addons/supabase/base_error.gd b/addons/supabase/base_error.gd index 67b12c9..fb350bb 100644 --- a/addons/supabase/base_error.gd +++ b/addons/supabase/base_error.gd @@ -4,6 +4,7 @@ class_name BaseError var _error : Dictionary var code : String = "empty" +var type : String = "empty" var message : String = "empty" var hint : String = "empty" var details diff --git a/addons/supabase/base_task.gd b/addons/supabase/base_task.gd index d60d606..63f7b43 100644 --- a/addons/supabase/base_task.gd +++ b/addons/supabase/base_task.gd @@ -31,6 +31,7 @@ func match_code(code : int) -> int: return -1 func push_request(httprequest : HTTPRequest) -> void: + reference() httprequest.request_completed.connect(_on_task_completed.bind(httprequest)) httprequest.request(_endpoint, _headers, true, _method, _payload) @@ -41,6 +42,7 @@ func _complete(_data = null, _error : BaseError = null) -> void: data = _data error = _error completed.emit(self) + unreference() func _to_string() -> String: return "%s, %s" % [data, error]