go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/cron/errors.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package cron 9 10 import "errors" 11 12 var ( 13 // ErrJobNotLoaded is a common error. 14 ErrJobNotLoaded = errors.New("job not loaded") 15 // ErrJobAlreadyLoaded is a common error. 16 ErrJobAlreadyLoaded = errors.New("job already loaded") 17 // ErrJobCanceled is a common error. 18 ErrJobCanceled = errors.New("job canceled") 19 // ErrJobAlreadyRunning is a common error. 20 ErrJobAlreadyRunning = errors.New("job already running") 21 ) 22 23 var ( 24 // ErrCannotStart is a common error. 25 ErrCannotStart = errors.New("cannot start; already started") 26 // ErrCannotStop is a common error. 27 ErrCannotStop = errors.New("cannot stop; already stopped") 28 ) 29 30 // IsJobNotLoaded returns if the error is a job not loaded error. 31 func IsJobNotLoaded(err error) bool { 32 return errors.Is(err, ErrJobNotLoaded) 33 } 34 35 // IsJobAlreadyLoaded returns if the error is a job already loaded error. 36 func IsJobAlreadyLoaded(err error) bool { 37 return errors.Is(err, ErrJobAlreadyLoaded) 38 } 39 40 // IsJobCanceled returns if the error is a task not found error. 41 func IsJobCanceled(err error) bool { 42 return errors.Is(err, ErrJobCanceled) 43 } 44 45 // IsJobAlreadyRunning returns if the error is a task not found error. 46 func IsJobAlreadyRunning(err error) bool { 47 return errors.Is(err, ErrJobAlreadyRunning) 48 }