rothiotome / godot-very-simple-twitch

Very Simple Twitch Chat integration for Godot
MIT License
46 stars 6 forks source link

[Feature]: Add api errors #9

Closed Laurick closed 7 months ago

Laurick commented 9 months ago

Description

In order to get more information about the failure flow at the api calls we need to return an error object with the information parsed to app

Current Behavior

The api client returns nulls with no information about the error itself.

How

Since Godot is not static typed we can use it to return an response ( like an 'ok' for timeouts) or an object error (VSTError?) with the following params:

In the other hand if we took this aproach every response from the api must be casted to response or the error class. I think that add a lot of overhead so we can:

  1. Parse all the responses to objects that will inherit from another one called VSTError and only check the errorCode ( much faster and ligther )
  2. Refactor a little bit the api script to add in every call 2 Callables one to be called when the api call was success and the other when the call was a failure ( Example -> _"func add_vip(user_to_vip_id: String, on_success_callback:Callable = null, on_failurecallback:Callable = null)")
  3. Make a big refactor and make a "ApiRequest" class and using Builder pattern to add all the data and the callbacks.
rothiotome commented 9 months ago

I think this should be our first priorioty right now. We don't control any API call and it's a problem if the supposed flow fails. Let's work on this right now