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

fix: StorageError shape to match returned errors from API #214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

putcho01
Copy link

@putcho01 putcho01 commented Nov 4, 2024

What kind of change does this PR introduce?

#165

What is the current behavior?

The StorageApiError class defined in storage-js has a status field.
The StorageError defined in storage-api has a statusCode field.

This mismatch make it difficult to correctly handle errors on the frontend.
I'd like to use the isStorageError function defined in storage-js, but it does not recognize errors thrown from the API

What is the new behavior?

Update StorageApiError class and error handling to match API returned errors

  • Change StorageApiError class in src/lib/errors.ts to have a statusCode field instead of status
  • Update toJSON method in StorageApiError class to return statusCode instead of status
  • Modify handleError function in src/lib/fetch.ts to handle statusCode instead of status

Additional context

Supabase Storage API scheme
https://supabase.github.io/storage/

errorScheme {
  statusCode*	string
  error*	string
  message*	string
}

@putcho01 putcho01 changed the title Fix StorageError shape to match returned errors from API fix: StorageError shape to match returned errors from API Nov 4, 2024
@hmpthz
Copy link

hmpthz commented Nov 21, 2024

I believe this is not the problem about StorageError, which is handled and constructed by handleError in lib/fetch.ts.

The problem is that for some reasons upload APIs are not using these helper functions while others do. You can check my PR #216

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

Successfully merging this pull request may close these issues.

2 participants