Skip to content

Commit 0890434

Browse files
committed
feat: format class
1 parent e8522ca commit 0890434

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

Storage/Exceptions/FailureHint.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44
namespace Supabase.Storage.Exceptions
55
{
66
public static class FailureHint
7-
{
8-
public enum Reason
9-
{
10-
Unknown,
11-
NotAuthorized,
12-
Internal,
13-
NotFound,
14-
AlreadyExists,
15-
InvalidInput
16-
}
17-
18-
public static Reason DetectReason(SupabaseStorageException storageException)
19-
{
20-
if (storageException.Content == null)
21-
return Unknown;
22-
23-
return storageException.StatusCode switch
24-
{
25-
400 when storageException.Content.ToLower().Contains("authorization") => NotAuthorized,
26-
400 when storageException.Content.ToLower().Contains("malformed") => NotAuthorized,
27-
400 when storageException.Content.ToLower().Contains("invalid signature") => NotAuthorized,
28-
400 when storageException.Content.ToLower().Contains("invalid") => InvalidInput,
29-
401 => NotAuthorized,
30-
403 when storageException.Content.ToLower().Contains("invalid compact jws") => NotAuthorized,
31-
403 when storageException.Content.ToLower().Contains("signature verification failed") => NotAuthorized,
32-
404 when storageException.Content.ToLower().Contains("not found") => NotFound,
33-
409 when storageException.Content.ToLower().Contains("exists") => AlreadyExists,
34-
500 => Internal,
35-
_ => Unknown
36-
};
37-
}
38-
}
39-
40-
}
7+
{
8+
public enum Reason
9+
{
10+
Unknown,
11+
NotAuthorized,
12+
Internal,
13+
NotFound,
14+
AlreadyExists,
15+
InvalidInput
16+
}
17+
18+
public static Reason DetectReason(SupabaseStorageException storageException)
19+
{
20+
if (storageException.Content == null)
21+
return Unknown;
22+
23+
return storageException.StatusCode switch
24+
{
25+
400 when storageException.Content.ToLower().Contains("authorization") => NotAuthorized,
26+
400 when storageException.Content.ToLower().Contains("malformed") => NotAuthorized,
27+
400 when storageException.Content.ToLower().Contains("invalid signature") => NotAuthorized,
28+
400 when storageException.Content.ToLower().Contains("invalid") => InvalidInput,
29+
401 => NotAuthorized,
30+
403 when storageException.Content.ToLower().Contains("invalid compact jws") => NotAuthorized,
31+
403 when storageException.Content.ToLower().Contains("signature verification failed") => NotAuthorized,
32+
404 when storageException.Content.ToLower().Contains("not found") => NotFound,
33+
409 when storageException.Content.ToLower().Contains("exists") => AlreadyExists,
34+
500 => Internal,
35+
_ => Unknown
36+
};
37+
}
38+
}
39+
40+
}

0 commit comments

Comments
 (0)