Start a new topic

iOS SDK 3.3.0 error localizedDescription

When returning a valid error, for example, during login with an incorrect password, please could you provide a more friendly error.localizedDescription like "Username or password incorrect".


For this example, we receive the following localizedDescription: "The operation couldn't be completed. (Kinvey.Error error 6.)"


Alternatively, please provide a list of error codes that we can use to generate our own error messages.


Thanks


Graeme,


Please check out this link:

http://devcenter.kinvey.com/ios-v3.0/reference/api/Enums/Error.html



Thanks,

Pranav

Kinvey Support

Hi Pranav


Thanks.  However, I don't seem to be able to access the .ErrorType property?  Could you perhaps provide an example of how to use it?


The documentation does not show the error code.  Can I assume it is 1 to x, from top to bottom?


In SDK 1.40, the localizedDescription provided a usable error message for an end user.  Is their a plan to provide the same in SDK 3.3?


Thanks

Hello Graeme,


We have escalated this request to Engineering for resolution. Thanks for reporting it. 


Regards,


Billy Gee

MLIBZ-1394

Is there any word on this?  I'm using IOS SDK 3.3.6, and I'm trying to display an error message when calling User.signup, specifically when there is already a user with the given username.

Hello Michael,


We have sent a request for Engineering for status. We will update this ticket when we hear back.


Regards,


Billy Gee

Hello Michael,


I think that there's a good chance that we can get a new error message in the SDK in the next release. I would like to run this past you and let me know if this solution would work for you? Let us know.


"Invalid credentials. Please retry your request with correct credentials"

 

        User.login(username: "test", password: "wrongPassword") { (user, error) in
            if let user = user {
                print("\(user)")
            } else if let error = error {
                print("\(error)") //printed "Invalid credentials. Please retry your request with correct credentials"
            }
        }

Hey Billy - Is the example you're giving something to use as a temporary solution until error messages are added in the next release? If so, it's not a very good solution, but maybe there's no other options. I can't be the only person having this issue... almost everyone using Kinvey has to do signup and login, and provide meaningful error messages....how do other people handle this?


Or are you asking me if this is a good solution for the next release? If so - using that example, how would I know that the error was invalid credentials, and not some other error? I just need a way to be able to inspect the error object returned, and display an appropriate error message. I would need this for all error endpoints, not just login. For example, on signup, I need a way to know if the signup failed because there is already a user with the given username.






Hi Billy - Just checking in on this, to see if there's any news... thanks....


Mike


Hello Michael,


Originally you were asking about the error message (text string) being more specific. Then your last couple of posts mentioned the error itself. Could you restate your requirements again just so we're clear.


Additionally, one of our iOS developers asked me to pass this snippet of code along as an example of what should be returned in the object. Hopefully we'll better understand what you're asking about.


Regards,


Billy Gee


User.login(username: "test", password: "test2") { (user, error) in
            if let user = user {
                print("\(user)")
            } else if let error = error {
                if let kinveyError = error as? Kinvey.Error {
                    switch kinveyError {
                    case .unauthorized(let response, let data, let error, let description):
                        print("Response: \(response)") //401 statusCode also included here
                        print("Data: \(String(data: data!, encoding: .utf8))")
                        print("Error: \(error)")
                        print("Description: \(description)")
                    default:
                        print("\(error)")
                    }
                }
            }
        }

Hi Billy - Sorry for the confusion. What may be causing some of the confusion is that this thread was started by someone else.


But I have error reporting on User.login working now: if the username does not exist, kinveyError.description contains "Invalid credentials. Please retry your request with correct credentials", which is good, because I can display that to the user.


My original question, though, was about User.signup. If the username already exists, kinveyError.description contains "unknownJsonError" instead of a meaningful error message.


Ideally I'd like to have a single error handler which displays error messages for all Kinvey calls.


Hello Michael,


So your main issue name may be the User.signup problem, we have released a new version of the iOS SDK v3.3.7 that improves on the error messaging and a couple of other fixes. I'm not sure if that interests you now but I wanted to let you know if it is available if you want to give it a try. It can be downloaded at the following URL.


http://devcenter.kinvey.com/ios/downloads


As for the User.signup problem, we would recommend starting a new post for that problem so that we don't get it mixed up with other discussions on this thread.


Please let us know if you have any feedback regarding the new update.


Regards,


Billy

Login or Signup to post a comment