2021-05-08 16:03:21 +00:00
|
|
|
package syncstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Blob struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Bookmarks string `json:"bookmarks"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
LastUpdated time.Time `json:"lastUpdated"`
|
|
|
|
LastAccessed time.Time `json:"lastAccessed"`
|
|
|
|
}
|
|
|
|
|
|
|
|
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}}
|
|
|
|
}
|
|
|
|
|
|
|
|
var NotImplementedError = NewSyncError(
|
|
|
|
"NotImplementedException",
|
|
|
|
"The requested route has not been implemented",
|
|
|
|
http.StatusNotFound)
|
|
|
|
|
|
|
|
var MethodNotImplementedError = NewSyncError(
|
|
|
|
"NotImplementedException",
|
|
|
|
"The requested method has not been implemented",
|
|
|
|
http.StatusMethodNotAllowed)
|
|
|
|
|
|
|
|
var SyncNotFoundError = NewSyncError(
|
|
|
|
"SyncNotFoundException",
|
|
|
|
"Sync does not exist",
|
|
|
|
http.StatusUnauthorized)
|
|
|
|
|
|
|
|
var SyncConflictError = NewSyncError(
|
|
|
|
"SyncConflictException",
|
|
|
|
"A sync conflict was detected",
|
|
|
|
http.StatusConflict)
|
2021-05-16 15:46:05 +00:00
|
|
|
|
|
|
|
var SyncDataLimitExceededError = NewSyncError(
|
|
|
|
"SyncDataLimitExceededException",
|
|
|
|
"Sync data limit exceeded",
|
|
|
|
http.StatusRequestEntityTooLarge)
|