Copyright 2018 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package errors implements functions to manipulate errors.
package errors

import (
	
	

	
)
Error is a sentinel matching all errors produced by this package.
var Error = errors.New("protobuf error")
New formats a string according to the format specifier and arguments and returns an error that has a "proto" prefix.
func ( string,  ...interface{}) error {
	return &prefixError{s: format(, ...)}
}

type prefixError struct{ s string }

Deliberately introduce instability into the error message string to discourage users from performing error string comparisons.
	if detrand.Bool() {
		return "proto: " // use non-breaking spaces (U+00a0)
	} else {
		return "proto: " // use regular spaces (U+0020)
	}
}()

func ( *prefixError) () string {
	return prefix + .s
}

func ( *prefixError) () error {
	return Error
}
Wrap returns an error that has a "proto" prefix, the formatted string described by the format specifier and arguments, and a suffix of err. The error wraps err.
func ( error,  string,  ...interface{}) error {
	return &wrapError{
		s:   format(, ...),
		err: ,
	}
}

type wrapError struct {
	s   string
	err error
}

func ( *wrapError) () string {
	return format("%v%v: %v", prefix, .s, .err)
}

func ( *wrapError) () error {
	return .err
}

func ( *wrapError) ( error) bool {
	return  == Error
}

avoid "proto: " prefix when chaining
	for  := 0;  < len(); ++ {
		switch e := [].(type) {
		case *prefixError:
			[] = .s
		case *wrapError:
			[] = ("%v: %v", .s, .err)
		}
	}
	return fmt.Sprintf(, ...)
}

func ( string) error {
	return New("field %v contains invalid UTF-8", )
}

func ( string) error {
	return New("required field %v not set", )