Skip to content

Bug: 'NoSuchBucket' Exception is thrown when an object doesn't exists. #32

@krwu

Description

@krwu

When you try to retrieve a non-exist object from an exists bucket, It should throw NoSuchKeyException, not NoSuchBucketException.

Test code:

$client = new Client(array(
    'region' => 'gz',
    'credentials' => array(
        'appId' => '{appId}',
        'secretId' => '{secretId}',
        'secretKey' => '{secretKey}'
    )
));

try {
    $result = $client->headObject(array(
        'Bucket' => '{exists bucket}',
        'Key' => '{non-exists key}'
    ));
    print_r($result);
} catch ( NoSuchKeyException $e ) {
    echo 'No such key.';
} catch ( NoSuchBucketException $e) {
    echo 'No such bucket.';
}

The output will be "No such bucket."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions