sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/config/store/errors.go (about)

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package store
    18  
    19  import (
    20  	"fmt"
    21  )
    22  
    23  // LoadError wraps errors yielded by Store.Load and Store.LoadFrom methods
    24  type LoadError struct {
    25  	Err error
    26  }
    27  
    28  // Error implements error interface
    29  func (e LoadError) Error() string {
    30  	return fmt.Sprintf("unable to load the configuration: %v", e.Err)
    31  }
    32  
    33  // Unwrap implements Wrapper interface
    34  func (e LoadError) Unwrap() error {
    35  	return e.Err
    36  }
    37  
    38  // SaveError wraps errors yielded by Store.Save and Store.SaveTo methods
    39  type SaveError struct {
    40  	Err error
    41  }
    42  
    43  // Error implements error interface
    44  func (e SaveError) Error() string {
    45  	return fmt.Sprintf("unable to save the configuration: %v", e.Err)
    46  }
    47  
    48  // Unwrap implements Wrapper interface
    49  func (e SaveError) Unwrap() error {
    50  	return e.Err
    51  }