cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Ross uses Dropbox to answer some new house questions here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SwiftyDropbox - how to catch improperly formatted path

SwiftyDropbox - how to catch improperly formatted path

vewert
Explorer | Level 4

If I make a call, (e.g. using listFolder), and I pass in an invalid path argument, (e.g. no leading slash), I get the following error:

 

precondition failed: "Does not exist must match pattern "\A(?:(/(.|[\r\n])*)?|id:.*|(ns:[0-9]+(/.*)?))\z":

 

I understand why the error occurs, but the error seems to occur, before the call gets made, and doesn't show up, when I check the response for an error. My question is, how can I catch this kind of error of the path argument?

 

Thanks

1 Accepted Solution

Accepted Solutions

Re: SwiftyDropbox - how to catch improperly formatted path

Greg-DB
Dropboxer
The SDK has a copy of the API specification and can tell when the supplied value isn't valid without making a call to the server (and thus without going through the API error callback).

You'll need to prevent your app from using invalid values like this in the first place. E.g., only use safe values returned by the API, such as in Metadata.pathLower, or just "" for root. If your app allows the user to manually enter in path values, you'll need to check them against the pattern in that error message first.

View solution in original post

2 Replies 2

Re: SwiftyDropbox - how to catch improperly formatted path

Greg-DB
Dropboxer
The SDK has a copy of the API specification and can tell when the supplied value isn't valid without making a call to the server (and thus without going through the API error callback).

You'll need to prevent your app from using invalid values like this in the first place. E.g., only use safe values returned by the API, such as in Metadata.pathLower, or just "" for root. If your app allows the user to manually enter in path values, you'll need to check them against the pattern in that error message first.

View solution in original post

Re: SwiftyDropbox - how to catch improperly formatted path

vewert
Explorer | Level 4

That makes sense. I'll make sure my app uses only valid values for path.

 

Thanks again for your quick and helpful response.

Who's talking

Top contributors to this post

  • User avatar
    vewert Explorer | Level 4
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?