<commit_before>// Copyright 2014 <NAME>.  All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
	"bytes"
	"encoding/json"
	"fmt"
	"reflect"
)

const (
	ErrorTypeBind    = 1 << 31
	ErrorTypeRender  = 1 << 30
	ErrorTypePrivate = 1 << 0
	ErrorTypePublic  = 1 << 1

	ErrorTypeAny = 0xffffffff
	ErrorTypeNu  = 2
)

type (
	Error struct {
		Err  error       `json:"error"`
		Type int         `json:"-"`
		Meta interface{} `json:"meta"`
	}

	errorMsgs []*Error
)

var _ error = &Error{}

func (msg *Error) SetType(flags int) *Error {
	msg.Type = flags
	return msg
}

func (msg *Error) SetMeta(data interface{}) *Error {
	msg.Meta = data
	return msg
}

func (msg *Error) JSON() interface{} {
	json := H{}
	if msg.Meta != nil {
		value := reflect.ValueOf(msg.Meta)
		switch value.Kind() {
		case reflect.Struct:<commit_msg>patch for #298<commit_after>// Copyright 2014 <NAME>.  All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
	"bytes"
	"encoding/json"
	"fmt"
	"reflect"
)

const (
	ErrorTypeBind    = 1 << 30
	ErrorTypeRender  = 1 << 29
	ErrorTypePrivate = 1 << 0
	ErrorTypePublic  = 1 << 1

	ErrorTypeAny = 0xfffffff
	ErrorTypeNu  = 2
)

type (
	Error struct {
		Err  error       `json:"error"`
		Type int         `json:"-"`
		Meta interface{} `json:"meta"`
	}

	errorMsgs []*Error
)

var _ error = &Error{}

func (msg *Error) SetType(flags int) *Error {
	msg.Type = flags
	return msg
}

func (msg *Error) SetMeta(data interface{}) *Error {
	msg.Meta = data
	return msg
}

func (msg *Error) JSON() interface{} {
	json := H{}
	if msg.Meta != nil {
		value := reflect.ValueOf(msg.Meta)
		switch value.Kind() {
		case reflect.Struct:
{'fraction_non_alphanumeric': 0.1327092511013216, 'fraction_numerical': 0.019273127753303965, 'mean_word_length': 3.138952164009112, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6011199', 'n_tokens_mistral': 692, 'n_tokens_neox': 634, 'n_words': 209}