We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
vewert
8 years agoExplorer | Level 4
SwiftyDropbox - how to catch improperly formatted path
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
- 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.
2 Replies
- Greg-DB8 years ago
Dropbox Community Moderator
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. - vewert8 years agoExplorer | 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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 hours ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!