File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 7
7
import org .vss .ErrorCode ;
8
8
import org .vss .ErrorResponse ;
9
9
import org .vss .KVStore ;
10
+ import org .vss .exception .AuthException ;
10
11
import org .vss .exception .ConflictException ;
11
12
import org .vss .exception .NoSuchKeyException ;
12
13
@@ -39,6 +40,9 @@ Response toErrorResponse(Exception e) {
39
40
} else if (e instanceof NoSuchKeyException ) {
40
41
errorCode = ErrorCode .NO_SUCH_KEY_EXCEPTION ;
41
42
statusCode = 404 ;
43
+ } else if (e instanceof AuthException ) {
44
+ errorCode = ErrorCode .AUTH_EXCEPTION ;
45
+ statusCode = 401 ;
42
46
} else {
43
47
errorCode = ErrorCode .INTERNAL_SERVER_EXCEPTION ;
44
48
statusCode = 500 ;
Original file line number Diff line number Diff line change
1
+ package org .vss .exception ;
2
+
3
+ public class AuthException extends RuntimeException {
4
+ public AuthException (String message ) {
5
+ super (message );
6
+ }
7
+ }
Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ enum ErrorCode {
268
268
269
269
// Used when the request contains mismatched version (either key or global)
270
270
// in `PutObjectRequest`. For more info refer `PutObjectRequest`.
271
- CONFLICT_EXCEPTION = 1 ;
271
+ CONFLICT_EXCEPTION = 1 ;
272
272
273
273
// Used in the following cases:
274
274
// - The request was missing a required argument.
@@ -282,6 +282,9 @@ enum ErrorCode {
282
282
283
283
// Used when the specified `key` in a `GetObjectRequest` does not exist.
284
284
NO_SUCH_KEY_EXCEPTION = 4 ;
285
+
286
+ // Used when authentication fails or in case of an unauthorized request.
287
+ AUTH_EXCEPTION = 5 ;
285
288
}
286
289
287
290
// Represents a key-value pair to be stored or retrieved.
You can’t perform that action at this time.
0 commit comments