cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

How to capture the error message

Highlighted

How to capture the error message

Helpful | Level 6

I want to capture the error message so I can do different actions depending on the text.  I can't figure out how to code this.  Here's my code...

        if DropboxClientsManager.authorizedClient != nil {
            print("We have an authorized client.  Now let's see if we can get the file attributes")
            
            // Check to see if Nvelopes.csv exists in Dropbox.
//            client!.files.getMetadata(path: "/Nvelopes.csv")
             client!.files.getMetadata(path: "/Nvelopes1.csv")
                .response {_ , error in
                    if let error = error {
                        print("We did not get the attributes :(")
                        print(error.description)
                        self.window?.rootViewController = mainStoryboard.instantiateViewController(withIdentifier: "sbLinkToDropbox") as UIViewController
                                            }
             }
            
        }

... and here's the result of print(error.description):

[request-id 7185a7cb73542868da1649971559a895] API route error - {
    ".tag" = path;
    path =     {
        ".tag" = "not_found";
    };
}

How do I capture the part after ".tag" =??

Thanks for your patience!

1 Accepted Solution

Accepted Solutions
Highlighted

Re: How to capture the error message

Dropboxer

There's an example of breaking down the error like this in the readme here:

https://github.com/dropbox/SwiftyDropbox#route-specific-errors

That example is for the delete call, but the mechanic is the same. For getMetadata, the route-specific error type is GetMetadataError.

Be sure to check out the section right after that for an example of handling higher-level errors too.

You can make the error handling as broad or as specific as you wish by breaking out each case (or not).

View solution in original post

2 Replies 2
Highlighted

Re: How to capture the error message

Dropboxer

There's an example of breaking down the error like this in the readme here:

https://github.com/dropbox/SwiftyDropbox#route-specific-errors

That example is for the delete call, but the mechanic is the same. For getMetadata, the route-specific error type is GetMetadataError.

Be sure to check out the section right after that for an example of handling higher-level errors too.

You can make the error handling as broad or as specific as you wish by breaking out each case (or not).

View solution in original post

Highlighted

Re: How to capture the error message

Helpful | Level 6

Thanks again, Greg

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?