oko-server/errs/errors.go
zegkljan 7deb7e3f39
All checks were successful
continuous-integration/drone/push Build is passing
refining photo handling
* photo metedata provided with downloaded data
* data download recognizes application/json and application/zip accepted types and serves bare json and zip with photos respectively
* thumbnail handling and storage
2022-02-19 23:38:58 +01:00

80 lines
2.2 KiB
Go

package errs
import "fmt"
type ConstError string
func (e ConstError) Error() string {
return string(e)
}
const (
ErrUserNotExists = ConstError("user does not exist")
ErrUserAlreadyExists = ConstError("user already exists")
ErrPhotoNotExists = ConstError("photo does not exist (for the given feature)")
ErrAttemptedSystemUser = ConstError("attempted to associate with system user")
ErrUnsupportedImageFormat = ConstError("unsupported image format")
ErrUnsupportedImageContentType = ConstError("unsupported image content type")
ErrNonUniqueCreatedFeatureIDs = ConstError("created features do not have unique IDs")
)
type EErrPhotoNotProvided *ErrPhotoNotProvided
type ErrPhotoNotProvided struct {
Reference string
}
func NewErrPhotoNotProvided(reference string) *ErrPhotoNotProvided {
return &ErrPhotoNotProvided{
Reference: reference,
}
}
func (e *ErrPhotoNotProvided) Error() string {
return fmt.Sprintf("referenced photo %s which was not provided", e.Reference)
}
type EErrPhotoThumbnailNotProvided *ErrPhotoThumbnailNotProvided
type ErrPhotoThumbnailNotProvided struct {
Reference string
}
func NewErrPhotoThumbnailNotProvided(reference string) *ErrPhotoThumbnailNotProvided {
return &ErrPhotoThumbnailNotProvided{
Reference: reference,
}
}
func (e *ErrPhotoThumbnailNotProvided) Error() string {
return fmt.Sprintf("referenced photo %s the thumbnail of which was not provided", e.Reference)
}
type ErrFeatureForPhotoNotExists struct {
PhotoFeatureReference int64
}
func NewErrFeatureForPhotoNotExists(reference int64) *ErrFeatureForPhotoNotExists {
return &ErrFeatureForPhotoNotExists{
PhotoFeatureReference: reference,
}
}
func (e *ErrFeatureForPhotoNotExists) Error() string {
return fmt.Sprintf("photos were referenced for feature with local ID %d which does not exist in posted created features", e.PhotoFeatureReference)
}
type ErrUnsupportedContentType struct {
Reference string
}
func NewErrUnsupportedContentType(reference string) *ErrUnsupportedContentType {
return &ErrUnsupportedContentType{
Reference: reference,
}
}
func (e *ErrUnsupportedContentType) Error() string {
return fmt.Sprintf("photo %s has an unsupported Content-Type", e.Reference)
}