28 lines
640 B
Go
28 lines
640 B
Go
|
// 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)
|
||
|
}
|