Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while loading entries from database #10

Open
StepanPazderka opened this issue Nov 26, 2020 · 8 comments
Open

Issue while loading entries from database #10

StepanPazderka opened this issue Nov 26, 2020 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@StepanPazderka
Copy link

I am trying to use this package with example code, I ahve setup Access Token and ClientID, but this error is raised up everytime

Fatal error: 'try!' expression unexpectedly raised an error: SwiftProtobuf.BinaryDecodingError.truncated: file IGDB_SWIFT_API/ProtoRequest.swift, line 107

@husnjak
Copy link
Owner

husnjak commented Dec 4, 2020

@StepanPazderka Can I get some more information about this?
i am interested in the query and the code used

@husnjak husnjak self-assigned this Dec 4, 2020
@husnjak husnjak added the bug Something isn't working label Dec 4, 2020
@EthanG45
Copy link

EthanG45 commented Dec 4, 2020

This looks kind of similar to the error you get when you do too many requests at once? Not sure if that's possibly related.

@StepanPazderka
Copy link
Author

This is the source code that produces this error, it is possible that I am doing some newbie mistake. I am a junior swifter at this point:

Please add your api keys and access tokens

override func viewDidLoad() {
        super.viewDidLoad()

        let wrapper = IGDBWrapper(clientID: "", accessToken: "")

        let apicalypse = APICalypse()
            .fields(fields: "*")
            .sort(field: "release_dates.date", order: .DESCENDING)

        wrapper.games(apiCalypse: apicalypse, result: { games in
            // Do something..
        }) { error in
            // Do something..
        }
    }

@husnjak
Copy link
Owner

husnjak commented Dec 7, 2020

When I am running your code in a test it seems to work just fine. thinking of @EthanG45 comment does this happen all the time for you? or just after some requests?
Because there is a rate-limit on the api that is 4 requests/second and if you exceed that you will get an error instead.
Also does your queries work in a api client such as Postman or Insomia?

@EthanG45
Copy link

EthanG45 commented Dec 8, 2020

I just wrote up a proof of concept game library app using the API in SwiftUI, and the only time I really saw errors were when I sent invalid queries or hit that rate limit. @StepanPazderka did you setup your API access token and what not properly?

Also @husnjak can I hijack and ask if you have a recommended way to catch errors when we do hit the rate limit? I'm also pretty new to programming in Swift and was unclear how to make use of the error closures provided.

@StepanPazderka
Copy link
Author

Could be that my tokens are not setup correctly. Sorry for that. I am not able to figure it out on my own, so if this API would do a better error handling with description for such cases, it would be great.

@EthanG45
Copy link

EthanG45 commented Dec 8, 2020

Could be that my tokens are not setup correctly. Sorry for that. I am not able to figure it out on my own, so if this API would do a better error handling with description for such cases, it would be great.

The console gives a descriptive message of where the error occurred and the response from IGDB. For instance spamming requests will show you the line where it attempted to generate a Proto_Game object and also say something like response too many requests at once.

I'm not sure what other messaging you'd want?

@observableobject
Copy link

Just leaving a comment here that I get this error as well in Xcode 12, even when copying in the examples in the Readme. It doesn't say anything about too many requests, it appears that the data is malformed.

Fatal error: 'try!' expression unexpectedly raised an error: SwiftProtobuf.BinaryDecodingError.malformedProtobuf: file IGDB_SWIFT_API/ProtoRequest.swift, line 107
(lldb)

I may create a new issue, if I can't figure out a solution. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants