Handle job failures and retries
masterCloudtasker communicates job status to Google Cloud Tasks via HTTP status codes. If a job returns an error, Cloud Tasks will trigger a retry based on your queue configuration.
HTTP Status Codes
204: Success.205: Job is dead (removed from queue).404: Incorrect worker class specified.422: Error occurred during worker execution (performmethod).
Worker Callbacks
Workers can implement specific callbacks to handle lifecycle events:
on_error(error): Called when a runtime error occurs duringperform.on_dead(error): Called when a job has exhausted all retries and is being removed from the queue.
class HandleErrorWorker
include Cloudtasker::Worker
def perform
raise(ArgumentError)
end
def on_error(error)
logger.error("The following error happened: #{error}")
end
def on_dead(error)
logger.error("The job died with the following error: #{error}")
end
end