Fix logs and recognition format
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.vakhrushev.me/av/transcriber/internal/entity"
|
||||
)
|
||||
|
||||
type JobNotFoundError struct {
|
||||
State string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *JobNotFoundError) Error() string {
|
||||
return fmt.Sprintf("%s - %s", e.State, e.Message)
|
||||
}
|
||||
|
||||
type FileRepository interface {
|
||||
Create(file *entity.File) error
|
||||
GetByID(id string) (*entity.File, error)
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.vakhrushev.me/av/transcriber/internal/entity"
|
||||
contracts "git.vakhrushev.me/av/transcriber/internal/repo"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
)
|
||||
|
||||
@@ -160,6 +161,10 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed check affected rows: %w", err)
|
||||
}
|
||||
if rowsAffected == 0 {
|
||||
e := contracts.JobNotFoundError{State: state, Message: "appropriate job not found"}
|
||||
return nil, &e
|
||||
}
|
||||
if rowsAffected != 1 {
|
||||
return nil, fmt.Errorf("unexpected affected rows count: %d", rowsAffected)
|
||||
}
|
||||
|
Reference in New Issue
Block a user