Archived
2
0
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
kerma/models/error.go

28 lines
640 B
Go
Raw Normal View History

2023-03-02 14:28:43 +00:00
// Package models provides the models for the KermaGo application
package models
import "github.com/docker/go/canonical/json"
/*
An Error represents a struct that has a type and an error message as a string
*/
type Error struct {
Type string `json:"type" binding:"required"`
Error string `json:"error" binding:"required"`
}
/*
Construct creates a new error object with the given string as message
*/
func (e *Error) Construct(errorMsg string) {
e.Type = "error"
e.Error = errorMsg
}
/*
MarshalJson returns the canonical json of the error object
*/
func (e *Error) MarshalJson() ([]byte, error) {
return json.MarshalCanonical(e)
}