// Code returns collector reason
332272
func (e *ErrToken) Code() string {

	switch e.message {
	case errCompressedTagMismatch:
		return collector.CompressedTagMismatch
	case errDatapathVersionMismatch:
		return collector.DatapathVersionMismatch
	default:
		return collector.InvalidToken
	}
}
504094
func Coded(code int32, msg string, detail ...string) *CodedError {
	e := &CodedError{
		Code:    code,
		Message: msg,
	}
	if len(detail) > 0 {
		e.Detail = detail[0]
	}
	return e
}
983331
func GenerateCode(secret string, counter uint64) (string, error) {
	return GenerateCodeCustom(secret, counter, ValidateOpts{
		Digits:    otp.DigitsSix,
		Algorithm: otp.AlgorithmSHA1,
	})
}
979630
func (h *TextWriter) WriteCode(w http.ResponseWriter, r *http.Request, code int, e interface{}) {
	if code == 0 {
		code = http.StatusOK
	}

	w.Header().Set("Content-Type", h.contentType)
	w.WriteHeader(code)
	fmt.Fprintf(w, "%s", e)
}
1226424
func VerificationCodeFilterByCode(code string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("code = ?", code)
	}
}
1075534
func (f *Finalizer) Code(att *design.AttributeDefinition, target string, depth int) string {
	buf := f.recurse(att, att, target, depth)
	return buf.String()
}
156972
func FindError(err error, code Code) Code {
	if err == nil {
		return NonError
	}

	if merr, ok := err.(*multierror.Error); ok {
		if merr.ErrorOrNil() == nil {
			return NonError
		}
		for _, e := range merr.Errors {
			if rfcErr, ok := e.(*Error); ok {
				if rfcErr.Code == code {
					return code
				}
			}
		}
	}
	return NonRFCError
}
761983
func buildCode() string {

	var clientFields = `{{if eq .Name "client" }}	//Use TLS when Send()ing
	UseTLS bool
	HttpClient *http.Client
{{end}}`

	var fields = `{{range $index, $element := .Fields}}	{{.PrivateName}} {{.Type}}{{if not .Required}}
	{{.PrivateName}}Set bool{{end}}
{{end}}`

	var paramVal = `{{if eq .Type "string"}}h.{{.PrivateName}}{{end}}` +
		`{{if eq .Type "bool"}}bool2str(h.{{.PrivateName}}){{end}}` +
		`{{if eq .Type "int64"}}int2str(h.{{.PrivateName}}){{end}}` +
		`{{if eq .Type "float64"}}float2str(h.{{.PrivateName}}){{end}}`

	var params = `{{range $index, $element := .Fields}}{{if ne .Param ""}}{{if not .Required}}	if h.{{.PrivateName}}Set {
{{end}}		v.Add({{.ParamStr}}, ` + paramVal + `){{if not .Required}}
	}{{end}}
{{end}}{{end}}`

	var constructorDocs = `{{if ne .Name "client" }}// New{{ .StructName }} ` +
		`creates a new {{ .StructName }} Hit Type.` +
		`{{range $index, $element := .Fields}}
		{{if .Required}}{{.Docs}}{{end}}{{end}}`

	var constructorParams = `{{range $index, $element := .Fields}}{{if .Required}}` +
		`{{if ne $index 0}},{{end}}{{.PrivateName}} {{.Type}}` +
		`{{end}}{{end}}`

	var constructor = constructorDocs + `
func New{{ .StructName }}(` + constructorParams + `) *{{.StructName}}	{
	h := &{{ .StructName }}{
{{range $index, $element := .Fields}}{{if .Required}}		{{.PrivateName}}: {{.PrivateName}},
{{end}}{{end}}	}
	return h
}{{end}}
`

	var clientFuncs = `{{if eq .Name "client" }}
func (c *Client) setType(h hitType) {
	switch h.(type) {
{{range $index, $id := .HitTypeIDs}}	case *{{ exportName $id}}:
		c.hitType = "{{ $id }}"
{{end}}	}
}
{{end}}`

	var setterFuncs = `{{range $index, $element := .Fields}}{{if not .Required}}{{.Docs}}
func (h *{{$.StructName}}) {{.Name}}({{.PrivateName}} {{.Type}}) *{{$.StructName}}	{
	h.{{.PrivateName}} = {{.PrivateName}}
	h.{{.PrivateName}}Set = true
	return h
}

{{end}}{{end}}`

	return `package ga

//WARNING: This file was generated. Do not edit.

//{{.StructName}} Hit Type
type {{.StructName}} struct {
` + clientFields + fields + `}

` + constructor + clientFuncs + `

func (h *{{.StructName}}) addFields(v url.Values) error {
` + params + `	return nil
}

` + setterFuncs + `

func (h *{{.StructName}}) Copy() *{{.StructName}} {
	c := *h
	return &c
}
`
}
957623
func (s *RecordError) SetCode(v string) *RecordError {
	s.Code = &v
	return s
}
977371
func (h *JSONWriter) WriteCode(w http.ResponseWriter, r *http.Request, code int, e interface{}) {
	js, err := json.Marshal(e)
	if err != nil {
		h.WriteError(w, r, errors.WithStack(err))
		return
	}

	if code == 0 {
		code = http.StatusOK
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(code)
	w.Write(js)
}
117452
func ExpectedCode(codes ...codes.Code) *CallOption {
	return &CallOption{
		grpc.EmptyCallOption{},
		func(o *Options) {
			o.expectedCodes = append(o.expectedCodes, codes...)
		},
	}
}
973051
func ErrorCode(err error) string {
	if err == nil {
		return ""
	}

	e, ok := err.(*Error)
	if !ok {
		return EInternal
	}

	if e == nil {
		return ""
	}

	if e.Code != "" {
		return e.Code
	}

	if e.Err != nil {
		return ErrorCode(e.Err)
	}

	return EInternal
}
859965
func WithCodes(f grpc_logging.ErrorToCode) Option {
	return func(o *options) {
		o.codeFunc = f
	}
}
1368351
func (s *Warning) SetCode(v string) *Warning {
	s.Code = &v
	return s
}
394912
func TypeCode(g Generator, spec compile.TypeSpec) string {
	wire := g.Import("go.uber.org/thriftrw/wire")
	spec = compile.RootTypeSpec(spec)

	switch spec.(type) {
	case *compile.BoolSpec:
		return fmt.Sprintf("%s.TBool", wire)
	case *compile.I8Spec:
		return fmt.Sprintf("%s.TI8", wire)
	case *compile.I16Spec:
		return fmt.Sprintf("%s.TI16", wire)
	case *compile.I32Spec:
		return fmt.Sprintf("%s.TI32", wire)
	case *compile.I64Spec:
		return fmt.Sprintf("%s.TI64", wire)
	case *compile.DoubleSpec:
		return fmt.Sprintf("%s.TDouble", wire)
	case *compile.StringSpec, *compile.BinarySpec:
		return fmt.Sprintf("%s.TBinary", wire)
	case *compile.MapSpec:
		return fmt.Sprintf("%s.TMap", wire)
	case *compile.ListSpec:
		return fmt.Sprintf("%s.TList", wire)
	case *compile.SetSpec:
		return fmt.Sprintf("%s.TSet", wire)
	case *compile.EnumSpec:
		return fmt.Sprintf("%s.TI32", wire)
	case *compile.StructSpec:
		return fmt.Sprintf("%s.TStruct", wire)
	default:
		panic(fmt.Sprintf("unknown type spec %v (type %T)", spec, spec))
	}
}
536530
func (process *process) ExitCode() (int, error) {
	code, err := process.p.ExitCode()
	if err != nil {
		err = convertProcessError(err, process)
	}
	return code, err
}
511652
func ServiceGoCode(svc *gen.ServiceMetadata, chars []*gen.CharacteristicMetadata) ([]byte, error) {
	var err error
	var buf bytes.Buffer

	data := ServiceDecl(svc, chars)

	t := template.New("Test Template")

	t, err = t.Parse(ServiceStructTemplate)
	t.Execute(&buf, data)

	return buf.Bytes(), err
}