// Convert MinIO errors to minio object layer errors.
199630
func gcsToObjectError(err error, params ...string) error {
	if err == nil {
		return nil
	}

	bucket := ""
	object := ""
	uploadID := ""
	if len(params) >= 1 {
		bucket = params[0]
	}
	if len(params) == 2 {
		object = params[1]
	}
	if len(params) == 3 {
		uploadID = params[2]
	}

	// in some cases just a plain error is being returned
	switch err.Error() {
	case "storage: bucket doesn't exist":
		err = minio.BucketNotFound{
			Bucket: bucket,
		}
		return err
	case "storage: object doesn't exist":
		if uploadID != "" {
			err = minio.InvalidUploadID{
				UploadID: uploadID,
			}
		} else {
			err = minio.ObjectNotFound{
				Bucket: bucket,
				Object: object,
			}
		}
		return err
	}

	googleAPIErr, ok := err.(*googleapi.Error)
	if !ok {
		// We don't interpret non MinIO errors. As minio errors will
		// have StatusCode to help to convert to object errors.
		return err
	}

	if len(googleAPIErr.Errors) == 0 {
		return err
	}

	reason := googleAPIErr.Errors[0].Reason
	message := googleAPIErr.Errors[0].Message

	switch reason {
	case "required":
		// Anonymous users does not have storage.xyz access to project 123.
		fallthrough
	case "keyInvalid":
		fallthrough
	case "forbidden":
		err = minio.PrefixAccessDenied{
			Bucket: bucket,
			Object: object,
		}
	case "invalid":
		err = minio.BucketNameInvalid{
			Bucket: bucket,
		}
	case "notFound":
		if object != "" {
			err = minio.ObjectNotFound{
				Bucket: bucket,
				Object: object,
			}
			break
		}
		err = minio.BucketNotFound{Bucket: bucket}
	case "conflict":
		if message == "You already own this bucket. Please select another name." {
			err = minio.BucketAlreadyOwnedByYou{Bucket: bucket}
			break
		}
		if message == "Sorry, that name is not available. Please try a different one." {
			err = minio.BucketAlreadyExists{Bucket: bucket}
			break
		}
		err = minio.BucketNotEmpty{Bucket: bucket}
	}

	return err
}
889768
func (md *MDOpsStandard) convertVerifyingKeyError(ctx context.Context,
	rmds *RootMetadataSigned, handle *tlfhandle.Handle, err error) error {
	if _, ok := err.(VerifyingKeyNotFoundError); !ok {
		return err
	}

	tlf := handle.GetCanonicalPath()
	writer, nameErr := md.config.KBPKI().GetNormalizedUsername(
		ctx, rmds.MD.LastModifyingWriter().AsUserOrTeam(),
		md.config.OfflineAvailabilityForPath(tlf))
	if nameErr != nil {
		writer = kbname.NormalizedUsername("uid: " +
			rmds.MD.LastModifyingWriter().String())
	}
	md.log.CDebugf(ctx, "Unverifiable update for TLF %s: %+v",
		rmds.MD.TlfID(), err)
	return UnverifiableTlfUpdateError{tlf, writer, err}
}
304015
func (m MultiError) Error() string {
	msgs := make([]string, len(m))
	for i, de := range m {
		msgs[i] = de.Error()
	}
	return strings.Join(msgs, "\n")
}
756966
func Convert_v1_MicroTime_To_v1_MicroTime(in *MicroTime, out *MicroTime, s conversion.Scope) error {
	// Cannot deep copy these, because time.Time has unexported fields.
	*out = *in
	return nil
}
912915
func deriveToError(err error, f func(vers string) (major int, minor int, ok bool)) func(vers string) (int, int, error) {
	return func(vers string) (int, int, error) {
		out0, out1, success := f(vers)
		if success {
			return out0, out1, nil
		}
		return out0, out1, err
	}
}
431084
func (s *Layer) UseError(fn c.HandlerFunc) Middleware {
	s.mtx.Lock()
	s.stack = append(s.stack, plugin.NewErrorPlugin(fn))
	s.mtx.Unlock()
	return s
}
981432
func ExtractMinWordSizefor2Typos(opts ...interface{}) *opt.MinWordSizefor2TyposOption {
	for _, o := range opts {
		if v, ok := o.(*opt.MinWordSizefor2TyposOption); ok {
			return v
		}
	}
	return nil
}
920579
func NewError(options ...func(*Error)) *Error {
	err := &Error{}
	for _, o := range options {
		o(err)
	}

	return err
}
1146051
func convertToError(code C.PmError) error {
	if code >= 0 {
		return nil
	}
	return errors.New(C.GoString(C.Pm_GetErrorText(code)))
}
351294
func MarshalErrors(w io.Writer, errorObjects []*ErrorObject) error {
	return json.NewEncoder(w).Encode(&ErrorsPayload{Errors: errorObjects})
}
760147
func migrateConfigToMinioSys(objAPI ObjectLayer) (err error) {
	// Construct path to config.json for the given bucket.
	configFile := path.Join(minioConfigPrefix, minioConfigFile)

	// Verify if config was already available in .minio.sys in which case, nothing more to be done.
	if err = checkConfig(context.Background(), objAPI, configFile); err != errConfigNotFound {
		return err
	}

	defer func() {
		// Rename config.json to config.json.deprecated only upon
		// success of this function.
		if err == nil {
			os.Rename(getConfigFile(), getConfigFile()+".deprecated")
		}
	}()

	transactionConfigFile := configFile + ".transaction"

	// As object layer's GetObject() and PutObject() take respective lock on minioMetaBucket
	// and configFile, take a transaction lock to avoid data race between readConfig()
	// and saveConfig().
	objLock := globalNSMutex.NewNSLock(minioMetaBucket, transactionConfigFile)
	if err = objLock.GetLock(globalOperationTimeout); err != nil {
		return err
	}
	defer objLock.Unlock()

	// Verify if backend already has the file (after holding lock)
	if err = checkConfig(context.Background(), objAPI, configFile); err != errConfigNotFound {
		return err
	} // if errConfigNotFound proceed to migrate..

	var config = &serverConfig{}
	if _, err = Load(getConfigFile(), config); err != nil {
		if !os.IsNotExist(err) {
			return err
		}
		// Read from deprecate file as well if necessary.
		if _, err = Load(getConfigFile()+".deprecated", config); err != nil {
			if !os.IsNotExist(err) {
				return err
			}
			// If all else fails simply initialize the server config.
			return newSrvConfig(objAPI)
		}

	}
	return saveServerConfig(context.Background(), objAPI, config)
}
191885
func (e ExecError) ShortError() string {
	outStr := e.truncateStr(e.StdOut, execShortErrorMaxLines)
	errStr := e.truncateStr(e.StdErr, execShortErrorMaxLines)
	return fmt.Sprintf(execErrorMsgFmt, e.Command, outStr, errStr)
}
533945
func CombineErrors(errs ...error) error {
	errs = RemoveNilErrors(errs)
	if len(errs) == 0 {
		return nil
	} else if len(errs) == 1 {
		return errs[0]
	}

	msgs := []string{}
	for _, err := range errs {
		msgs = append(msgs, err.Error())
	}
	return fmt.Errorf("There were multiple errors: %s", strings.Join(msgs, "; "))
}
1303254
func fromOSSClientListObjectsResult(bucket string, lor oss.ListObjectsResult) minio.ListObjectsInfo {
	objects := make([]minio.ObjectInfo, len(lor.Objects))
	for i, oi := range lor.Objects {
		objects[i] = fromOSSClientObjectProperties(bucket, oi)
	}

	prefixes := make([]string, len(lor.CommonPrefixes))
	copy(prefixes, lor.CommonPrefixes)

	return minio.ListObjectsInfo{
		IsTruncated: lor.IsTruncated,
		NextMarker:  lor.NextMarker,
		Objects:     objects,
		Prefixes:    prefixes,
	}
}
31436
func ErrAPINotSupported(message string) error {
	return ErrorResponse{
		StatusCode: http.StatusNotImplemented,
		Code:       "APINotSupported",
		Message:    message,
		RequestID:  "minio",
	}
}
1144185
func convertMapNumbers(m map[string]interface{}) error {
	var err error
	for k, v := range m {
		switch v := v.(type) {
		case json.Number:
			m[k], err = convertNumber(v)
		case map[string]interface{}:
			err = convertMapNumbers(v)
		case []interface{}:
			err = convertSliceNumbers(v)
		}
		if err != nil {
			return err
		}
	}
	return nil
}
868807
func (c *CompileContext) CaptureErrors(yes bool) {
	state := 0
	if yes {
		state = 1
	}

	C._go_mrb_context_set_capture_errors(c.ctx, C.int(state))
}