github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/job/errors.go (about)

     1  package job
     2  
     3  import (
     4  	"errors"
     5  	"net/http"
     6  
     7  	"github.com/labstack/echo/v4"
     8  )
     9  
    10  var (
    11  	// ErrClosed is using a closed system
    12  	ErrClosed = errors.New("jobs: closed")
    13  	// ErrNotFoundJob is used when the job could not be found
    14  	ErrNotFoundJob = errors.New("jobs: not found")
    15  	// ErrQueueClosed is used to indicate the queue is closed
    16  	ErrQueueClosed = errors.New("jobs: queue is closed")
    17  	// ErrUnknownWorker the asked worker does not exist
    18  	ErrUnknownWorker = errors.New("jobs: could not find worker")
    19  	// ErrMessageNil is used for an nil message
    20  	ErrMessageNil = errors.New("jobs: message is nil")
    21  	// ErrMessageUnmarshal is used when unmarshalling a message causes an error
    22  	ErrMessageUnmarshal = errors.New("jobs: message unmarshal")
    23  	// ErrAbort can be used to abort the execution of the job without causing
    24  	// errors.
    25  	ErrAbort = errors.New("jobs: abort")
    26  
    27  	// ErrUnknownTrigger is used when the trigger type is not recognized
    28  	ErrUnknownTrigger = errors.New("Unknown trigger type")
    29  	// ErrNotFoundTrigger is used when the trigger was not found
    30  	ErrNotFoundTrigger = errors.New("Trigger with specified ID does not exist")
    31  	// ErrMalformedTrigger is used to indicate the trigger is unparsable
    32  	ErrMalformedTrigger = echo.NewHTTPError(http.StatusBadRequest, "Trigger unparsable")
    33  	// ErrNotCronTrigger is used when a @cron trigger is expected, but it is
    34  	// not the case
    35  	ErrNotCronTrigger = errors.New("Invalid type for trigger (@cron expected)")
    36  )
    37  
    38  // BadTriggerError is an error conveying the information of a trigger that is not
    39  // valid, and could be deleted.
    40  type BadTriggerError struct {
    41  	Err error
    42  }
    43  
    44  func (e BadTriggerError) Error() string {
    45  	return e.Err.Error()
    46  }