code: func recoverPanic(j *Job) {
  	if r := recover(); r != nil {
  		// record an error on the job with panic message and stacktrace
  		stackBuf := make([]byte, 1024)
  		n := runtime.Stack(stackBuf, false)
  
  		buf := &bytes.Buffer{}
  		fmt.Fprintf(buf, "%v\n", r)
  		fmt.Fprintln(buf, string(stackBuf[:n]))
  		fmt.Fprintln(buf, "[...]")
  		stacktrace := buf.String()
  		log.Printf("event=panic job_id=%d job_type=%s\n%s", j.ID, j.Type, stacktrace)
  		if err := j.Error(stacktrace); err != nil {
  			log.Printf("attempting to save error on job %d: %v", j.ID, err)
  		}
  	}
  }
docs: // recoverPanic tries to handle panics in job execution.
  // A stacktrace is stored into Job last_error.