github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/bacerrors/imagenotfound.go (about)

     1  package bacerrors
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type ImageNotFound GenericError
     8  
     9  func NewImageNotFound(id string) *ImageNotFound {
    10  	var e ImageNotFound
    11  	e.Code = ErrorCodeImageNotFound
    12  	e.Message = fmt.Sprintf(ErrorMessageImageNotFound, id)
    13  	e.Details = make(map[string]interface{})
    14  	e.SetError(fmt.Errorf("%s", e.Message))
    15  	return &e
    16  }
    17  
    18  func (e *ImageNotFound) GetMessage() string {
    19  	return e.Message
    20  }
    21  func (e *ImageNotFound) SetMessage(s string) {
    22  	e.Message = s
    23  }
    24  
    25  func (e *ImageNotFound) Error() string {
    26  	return e.GetError().Error()
    27  }
    28  func (e *ImageNotFound) GetError() error {
    29  	return e.Err
    30  }
    31  func (e *ImageNotFound) SetError(err error) {
    32  	e.Err = err
    33  }
    34  
    35  func (e *ImageNotFound) GetCode() string {
    36  	return ErrorCodeImageNotFound
    37  }
    38  func (e *ImageNotFound) SetCode(string) {
    39  	e.Code = ErrorCodeImageNotFound
    40  }
    41  
    42  func (e *ImageNotFound) GetDetails() map[string]interface{} {
    43  	return e.Details
    44  }
    45  
    46  func (e *ImageNotFound) GetImageName() string {
    47  	if id, ok := e.Details["imagename"]; ok {
    48  		return id.(string)
    49  	}
    50  	return ""
    51  }
    52  func (e *ImageNotFound) SetImageName(s string) {
    53  	e.Details["imagename"] = s
    54  }
    55  
    56  const (
    57  	ErrorCodeImageNotFound = "error-image-not-found"
    58  
    59  	ErrorMessageImageNotFound = "Image not found. Image: %s"
    60  )
    61  
    62  var _ BacalhauErrorInterface = (*ImageNotFound)(nil)