I'm working on some software that synchronizes settings files with an AWS account, and occasionally things go wrong. It's fine - it's not specifically rclone's fault. AWS is usually nice enough to return an xml describing what went wrong - and I want to capture that.
I can use the flag --dump responses and that will show me exactly what I want to see in an error state - BUT if there is no error it ends up printing out a lot of binary data. Is there a way of only dumping that response in the case of a failing call?
the XML looks like this:
<Error> <Code>AccessDenied</Code> <Message>Request has expired</Message> <Expires>2019-06-13T12:12:43Z</Expires> <ServerTime>2022-08-11T22:20:22Z</ServerTime> <RequestId>foo</RequestId> <HostId> bar </HostId> </Error>
$ rclone --version
- os/version: ubuntu 18.04 (64 bit)
- os/kernel: 5.4.0-122-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.8
- go/linking: static
- go/tags: none
rclone copyurl --dump responses '<url>' <dest>
$ rclone copyurl '<url>' ./junk.tmp -vv 2022/08/11 22:18:12 DEBUG : rclone: Version "v1.58.0" starting with parameters ["rclone" "copyurl" "<url>" "./junk.tmp" "-vv"] 2022/08/11 22:18:12 DEBUG : Creating backend with remote "./" 2022/08/11 22:18:12 NOTICE: Config file "/home/trevor/.config/rclone/rclone.conf" not found - using defaults 2022/08/11 22:18:12 DEBUG : fs cache: renaming cache item "./" to be canonical "/home/trevor/src/f-ecoation-ros" 2022/08/11 22:18:13 ERROR : Attempt 1/3 failed with 1 errors and: CopyURL failed: 403 Forbidden 2022/08/11 22:18:13 ERROR : Attempt 2/3 failed with 1 errors and: CopyURL failed: 403 Forbidden 2022/08/11 22:18:13 ERROR : Attempt 3/3 failed with 1 errors and: CopyURL failed: 403 Forbidden 2022/08/11 22:18:13 INFO : Transferred: 0 B / 0 B, -, 0 B/s, ETA - Errors: 1 (retrying may help) Elapsed time: 0.4s 2022/08/11 22:18:13 DEBUG : 2 go routines active 2022/08/11 22:18:13 Failed to copyurl: CopyURL failed: 403 Forbidden