2021-05-08 16:03:21 +00:00
|
|
|
package syncstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ErrorPayload struct {
|
|
|
|
Code string `json:"code"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SyncError struct {
|
|
|
|
StatusCode int
|
|
|
|
Payload ErrorPayload
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e SyncError) Error() string {
|
|
|
|
return fmt.Sprintf("code: %s, message: %s", e.Payload.Code, e.Payload.Message)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSyncError(code string, message string, status int) SyncError {
|
|
|
|
return SyncError{
|
|
|
|
StatusCode: status,
|
|
|
|
Payload: ErrorPayload{
|
|
|
|
Code: code,
|
|
|
|
Message: message}}
|
|
|
|
}
|
|
|
|
|
2021-05-17 15:31:34 +00:00
|
|
|
var (
|
|
|
|
NotImplementedError = NewSyncError(
|
|
|
|
"NotImplementedException",
|
|
|
|
"The requested route has not been implemented",
|
|
|
|
http.StatusNotFound)
|
|
|
|
|
|
|
|
MethodNotImplementedError = NewSyncError(
|
|
|
|
"NotImplementedException",
|
|
|
|
"The requested method has not been implemented",
|
|
|
|
http.StatusMethodNotAllowed)
|
|
|
|
|
|
|
|
SyncNotFoundError = NewSyncError(
|
|
|
|
"SyncNotFoundException",
|
|
|
|
"Sync does not exist",
|
|
|
|
http.StatusUnauthorized)
|
|
|
|
|
|
|
|
SyncConflictError = NewSyncError(
|
|
|
|
"SyncConflictException",
|
|
|
|
"A sync conflict was detected",
|
|
|
|
http.StatusConflict)
|
|
|
|
|
|
|
|
SyncDataLimitExceededError = NewSyncError(
|
|
|
|
"SyncDataLimitExceededException",
|
|
|
|
"Sync data limit exceeded",
|
|
|
|
http.StatusRequestEntityTooLarge)
|
2021-05-17 20:59:43 +00:00
|
|
|
|
|
|
|
RequiredDataNotFoundError = NewSyncError(
|
|
|
|
"RequiredDataNotFoundException",
|
|
|
|
"Unable to find required data",
|
|
|
|
http.StatusBadRequest)
|
2021-05-17 15:31:34 +00:00
|
|
|
)
|