-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,253 additions
and
772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
package handlers | ||
|
||
import "git.epam.com/epm-lstr/epm-lstr-lc/be/internal/generated/swagger/models" | ||
import ( | ||
"net/http" | ||
|
||
func buildErrorPayload(err error) *models.Error { | ||
return &models.Error{ | ||
Data: &models.ErrorData{ | ||
Message: err.Error(), | ||
}, | ||
"git.epam.com/epm-lstr/epm-lstr-lc/be/internal/generated/swagger/models" | ||
) | ||
|
||
func buildErrorPayload(code int32, msg string, details string) *models.SwaggerError { | ||
return &models.SwaggerError{ | ||
Code: &code, | ||
Message: &msg, | ||
Details: details, // optional field for raw err messages | ||
} | ||
} | ||
|
||
func buildStringPayload(msg string) *models.Error { | ||
return &models.Error{ | ||
Data: &models.ErrorData{ | ||
Message: msg, | ||
}, | ||
} | ||
func buildInternalErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusInternalServerError, msg, details) | ||
} | ||
|
||
func buildExFailedErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusExpectationFailed, msg, details) | ||
} | ||
|
||
func buildConflictErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusConflict, msg, details) | ||
} | ||
|
||
func buildNotFoundErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusNotFound, msg, details) | ||
} | ||
|
||
func buildForbiddenErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusForbidden, msg, details) | ||
} | ||
|
||
func buildBadRequestErrorPayload(msg string, details string) *models.SwaggerError { | ||
return buildErrorPayload(http.StatusBadRequest, msg, details) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.