Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Both no bucket and no file are return 404 and NotFound. So I can't handle these. #1187

Open
username1103 opened this issue May 29, 2023 · 1 comment

Comments

@username1103
Copy link

username1103 commented May 29, 2023

Hi, I'm use this library with nodejs.

  const [result] = await this.client
    .bucket(this.config.options.bucket)
    .file(key)
    .download();

  return new File(key, result);

I want to handle no bucket error and no such key error.
When connected to actual cloud storage, I was able to distinguish it through messages. "The specified bucket does not exist", "No such object".

However, when using fake-gcs-server, even if there is no bucket or no object, the same error 404 ApiError: NotFound is provided, so it cannot be distinguished.

I received message "No such object" if object does not exist and bucket exists in actual cloud storage.
And received message "The specified bucket does not exist" if bucket does not exists in acual cloud storage.

Is there a way to handle both errors?

@fsouza
Copy link
Owner

fsouza commented May 29, 2023

We should try to make the messages the same (though that's very tricky as the actual error messages are not part of the API, so they could change at anytime).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants