Skip to content

Commit

Permalink
new error for invalid org data
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 16, 2024
1 parent cd995e3 commit c11c238
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ This method invalidates any previous JWT token for the user, so it returns a new
"subdomain": "mysubdomain",
"country": "Germany",
"timezone": "GMT+2",
"Language": "EN"
"language": "EN"
}
```
If the user want to create a sub org, the address of the root organization must be provided inside an organization object in `parent` param. The creator must be admin of the parent organization to be able to create suborganizations. Example:
Expand All @@ -349,6 +349,7 @@ If the user want to create a sub org, the address of the root organization must
| `401` | `40001` | `user not authorized` |
| `400` | `40004` | `malformed JSON body` |
| `400` | `40009` | `organization not found` |
| `400` | `40013` | `invalid organization data` |
| `500` | `50002` | `internal server error` |

### ⚙️ Update organization
Expand Down
1 change: 1 addition & 0 deletions api/errors_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
ErrMalformedURLParam = Error{Code: 40010, HTTPstatus: http.StatusBadRequest, Err: fmt.Errorf("malformed URL parameter")}
ErrNoOrganizationProvided = Error{Code: 40011, HTTPstatus: http.StatusBadRequest, Err: fmt.Errorf("no organization provided")}
ErrNoOrganizations = Error{Code: 40012, HTTPstatus: http.StatusNotFound, Err: fmt.Errorf("this user has not been assigned to any organization")}
ErrInvalidOrganizationData = Error{Code: 40013, HTTPstatus: http.StatusBadRequest, Err: fmt.Errorf("invalid organization data")}

ErrMarshalingServerJSONFailed = Error{Code: 50001, HTTPstatus: http.StatusInternalServerError, Err: fmt.Errorf("marshaling (server-side) JSON failed")}
ErrGenericInternalServerError = Error{Code: 50002, HTTPstatus: http.StatusInternalServerError, Err: fmt.Errorf("internal server error")}
Expand Down
2 changes: 1 addition & 1 deletion api/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (a *API) createOrganizationHandler(w http.ResponseWriter, r *http.Request)
Parent: parentOrg,
}); err != nil {
if err == db.ErrAlreadyExists {
ErrMalformedBody.WithErr(err).Write(w)
ErrInvalidOrganizationData.WithErr(err).Write(w)
return
}
ErrGenericInternalServerError.Write(w)
Expand Down

0 comments on commit c11c238

Please sign in to comment.