0

I'm trying to upload a file to s3 with php. I copied this code from GitHub, and after subbing in my credentials it seems to work fine. However there's one part in it that frankly I don't understand and seems to be written wrong.

They use two try statements and three catch blocks. Also they're named differently: one uses S3Exception, and the other uses just Exception. From what I understand S3Exception is correct and you should not have more catches than you do tries. Am I correct in my assumption?

Heres the link to the GitHub: link

} catch (S3Exception $e) {
        die('Error:' . $e->getMessage());
} catch (Exception $e) {
    die('Error:' . $e->getMessage());
}

1 Answer 1

1

You can have multiple catch blocks to do different things for different types of exceptions. In your case above, the first block will only catch S3Exceptions. The second block will catch all other types of exceptions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.