aboutsummaryrefslogtreecommitdiff
path: root/errors
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-09-03 16:18:20 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-09-03 16:18:20 +0530
commit776522d8741752832981b17ec81deb11a298ef57 (patch)
treef7c0654f2b3dbc475c2a32daa5c623eec0ffce4a /errors
parent95dfc551f7eaaf6e8ebdefce1b733951354ac40d (diff)
different customers for different users
Diffstat (limited to 'errors')
-rw-r--r--errors/errors.go5
-rw-r--r--errors/status.go5
2 files changed, 9 insertions, 1 deletions
diff --git a/errors/errors.go b/errors/errors.go
index 16e1646..6716fdc 100644
--- a/errors/errors.go
+++ b/errors/errors.go
@@ -42,6 +42,9 @@ var (
ErrUnauthorized = errors.New("Unauthorized")
ErrSessionExpired = errors.New("Session Expired")
+ // 403
+ ErrForbidden = errors.New("You Are Not Authorized To Access This Resource")
+
// 404
ErrNotFound = errors.New("Not Found")
ErrBrandNotFound = errors.New("This Brand Does Not Exist")
@@ -56,5 +59,5 @@ var (
ErrNonUniqueBrandItem = errors.New("Item With Same Name And Brand Already Exists")
// 500
- ErrInternalServerError = errors.New("Internal Server Error")
+ ErrInternalServerError = errors.New("Internal Server Error")
)
diff --git a/errors/status.go b/errors/status.go
index 4767aeb..1fa33d1 100644
--- a/errors/status.go
+++ b/errors/status.go
@@ -49,6 +49,11 @@ func StatusCodeFromErr(err error) int {
return http.StatusUnauthorized
}
+ // 403
+ if errors.Is(err, ErrForbidden) {
+ return http.StatusForbidden
+ }
+
// 404
if errors.Is(err, ErrNotFound) ||
errors.Is(err, ErrBrandNotFound) {