func newError(err ResultError, context *jsonContext, value interface{}, locale locale, details ErrorDetails) {
	var t string
	var d string
	switch err.(type) {
	case *RequiredError:
		t = "required"
		d = locale.Required()
	case *InvalidTypeError:
		t = "invalid_type"
		d = locale.InvalidType()
	case *NumberAnyOfError:
		t = "number_any_of"
		d = locale.NumberAnyOf()
	case *NumberOneOfError:
		t = "number_one_of"
		d = locale.NumberOneOf()
	case *NumberAllOfError:
		t = "number_all_of"
		d = locale.NumberAllOf()
	case *NumberNotError:
		t = "number_not"
		d = locale.NumberNot()
	case *MissingDependencyError:
		t = "missing_dependency"
		d = locale.MissingDependency()
	case *InternalError:
		t = "internal"
		d = locale.Internal()
	case *EnumError:
		t = "enum"
		d = locale.Enum()
	case *ArrayNoAdditionalItemsError:
		t = "array_no_additional_items"
		d = locale.ArrayNoAdditionalItems()
	case *ArrayMinItemsError:
		t = "array_min_items"
		d = locale.ArrayMinItems()
	case *ArrayMaxItemsError:
		t = "array_max_items"
		d = locale.ArrayMaxItems()
	case *ItemsMustBeUniqueError:
		t = "unique"
		d = locale.Unique()
	case *ArrayMinPropertiesError:
		t = "array_min_properties"
		d = locale.ArrayMinProperties()
	case *ArrayMaxPropertiesError:
		t = "array_max_properties"
		d = locale.ArrayMaxProperties()
	case *AdditionalPropertyNotAllowedError:
		t = "additional_property_not_allowed"
		d = locale.AdditionalPropertyNotAllowed()
	case *InvalidPropertyPatternError:
		t = "invalid_property_pattern"
		d = locale.InvalidPropertyPattern()
	case *StringLengthGTEError:
		t = "string_gte"
		d = locale.StringGTE()
	case *StringLengthLTEError:
		t = "string_lte"
		d = locale.StringLTE()
	case *DoesNotMatchPatternError:
		t = "pattern"
		d = locale.DoesNotMatchPattern()
	case *DoesNotMatchFormatError:
		t = "format"
		d = locale.DoesNotMatchFormat()
	case *MultipleOfError:
		t = "multiple_of"
		d = locale.MultipleOf()
	case *NumberGTEError:
		t = "number_gte"
		d = locale.NumberGTE()
	case *NumberGTError:
		t = "number_gt"
		d = locale.NumberGT()
	case *NumberLTEError:
		t = "number_lte"
		d = locale.NumberLTE()
	case *NumberLTError:
		t = "number_lt"
		d = locale.NumberLT()
	}
	err.SetType(t)
	err.SetContext(context)
	err.SetValue(value)
	err.SetDetails(details)
	details["field"] = err.Field()
	if _, exists := details["context"]; !exists && context != nil {
		details["context"] = context.String()
	}
	err.SetDescription(formatErrorDescription(d, details))
}
newError takes a ResultError type and sets the type, context, description, details, value, and field
package gojsonschema
import (
	"bytes"
	"sync"
	"text/template"
)
var errorTemplates errorTemplate = errorTemplate{template.New("errors-new"), sync.RWMutex{}}
type errorTemplate struct {
	*template.Template
	sync.RWMutex
}
type (
	RequiredError struct {
		ResultErrorFields
	}
	InvalidTypeError struct {
		ResultErrorFields
	}
	NumberAnyOfError struct {
		ResultErrorFields
	}
	NumberOneOfError struct {
		ResultErrorFields
	}
	NumberAllOfError struct {
		ResultErrorFields
	}
	NumberNotError struct {
		ResultErrorFields
	}
	MissingDependencyError struct {
		ResultErrorFields
	}
	InternalError struct {
		ResultErrorFields
	}
	EnumError struct {
		ResultErrorFields
	}
	ArrayNoAdditionalItemsError struct {
		ResultErrorFields
	}
	ArrayMinItemsError struct {
		ResultErrorFields
	}
	ArrayMaxItemsError struct {
		ResultErrorFields
	}
	ItemsMustBeUniqueError struct {
		ResultErrorFields
	}
	ArrayMinPropertiesError struct {
		ResultErrorFields
	}
	ArrayMaxPropertiesError struct {
		ResultErrorFields
	}
	AdditionalPropertyNotAllowedError struct {
		ResultErrorFields
	}
	InvalidPropertyPatternError struct {
		ResultErrorFields
	}
	StringLengthGTEError struct {
		ResultErrorFields
	}
	StringLengthLTEError struct {
		ResultErrorFields
	}
	DoesNotMatchPatternError struct {
		ResultErrorFields
	}
	DoesNotMatchFormatError struct {
		ResultErrorFields
	}
	MultipleOfError struct {
		ResultErrorFields
	}
	NumberGTEError struct {
		ResultErrorFields
	}
	NumberGTError struct {
		ResultErrorFields
	}
	NumberLTEError struct {
		ResultErrorFields
	}
	NumberLTError struct {
		ResultErrorFields
	}
)