func handleBasicAPIErrors(list transport.APIErrors, logger Logger) error {
	if list == nil || len(list) == 0 {
		return nil
	}

	if errs, _ := APIErrors(list); errs != nil {
		masked := true
		defer func() {
			// Only log out the error if we're masking the original error, that
			// way you can at least find the issue in `debug-log`.
			// We do this because the original error message can be huge and
			// verbose, like a java stack trace!
			if masked {
				logger.Errorf("charmhub API error %s:%s", errs[0].Code, errs[0].Message)
			}
		}()

		switch errs[0].Code {
		case transport.ErrorCodeNotFound:
			return errors.NotFoundf("charm or bundle")
		case transport.ErrorCodeNameNotFound:
			return errors.NotFoundf("charm or bundle name")
		case transport.ErrorCodeResourceNotFound:
			return errors.NotFoundf("charm resource")
		case transport.ErrorCodeAPIError:
			return errors.Errorf("unexpected api error attempting to query charm or bundle from the charmhub store")
		case transport.ErrorCodeBadArgument:
			return errors.BadRequestf("query argument")
		}
		// We haven't handled the errors, so just return them.
		masked = false
		return errs
	}
	return list
}
// Handle some of the basic error messages.
Handle some of the basic error messages.
// Handle some of the basic error messages .
func handleBasicAPIErrors(list transport.APIErrors, logger Logger) error {
	if list == nil || len(list) == 0 {
		return nil
	}
	if errs, _ := APIErrors(list); errs != nil {
		masked := true
		defer func() {
			if masked {
				logger.Errorf("charmhub API error %s:%s", errs[0].Code, errs[0].Message)
			}
		}()
		switch errs[0].Code {
		case transport.ErrorCodeNotFound:
			return errors.NotFoundf("charm or bundle")
		case transport.ErrorCodeNameNotFound:
			return errors.NotFoundf("charm or bundle name")
		case transport.ErrorCodeResourceNotFound:
			return errors.NotFoundf("charm resource")
		case transport.ErrorCodeAPIError:
			return errors.Errorf("unexpected api error attempting to query charm or bundle from the charmhub store")
		case transport.ErrorCodeBadArgument:
			return errors.BadRequestf("query argument")
		}
		masked = false
		return errs
	}
	return list
}
func handleBasicAPIErrors ( list transport . APIErrors , logger Logger ) error { if list == nil || len ( list ) == 0 { return nil } if errs , _ := APIErrors ( list ) ; errs != nil { masked := true defer func ( ) { if masked { logger . Errorf ( " " , errs [ 0 ] . Code , errs [ 0 ] . Message ) } } ( ) switch errs [ 0 ] . Code { case transport . ErrorCodeNotFound : return errors . NotFoundf ( " " ) case transport . ErrorCodeNameNotFound : return errors . NotFoundf ( " " ) case transport . ErrorCodeResourceNotFound : return errors . NotFoundf ( " " ) case transport . ErrorCodeAPIError : return errors . Errorf ( " " ) case transport . ErrorCodeBadArgument : return errors . BadRequestf ( " " ) } masked = false return errs } return list }
Handle some of the basic error messages.
Handle some of the basic error messages .
// Only log out the error if we're masking the original error, that // way you can at least find the issue in `debug-log`. // We do this because the original error message can be huge and // verbose, like a java stack trace! // We haven't handled the errors, so just return them.