Skip to content

Commit

Permalink
add errors for support/file
Browse files Browse the repository at this point in the history
  • Loading branch information
kkumar-gcc committed Oct 13, 2024
1 parent 920e9fd commit 0f04d58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions errors/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
DockerUnknownContainerType = New("unknown container type")
DockerInsufficientDatabaseContainers = New("the number of database container is not enough, expect: %d, got: %d")
DockerDatabaseContainerCountZero = New("the number of database container must be greater than 0")
DockerMissingContainerId = New("no container id return when creating %s docker")

AuthEmptySecret = New("authentication secret is missing or required")
AuthInvalidClaims = New("authentication token contains invalid claims")
Expand Down Expand Up @@ -96,6 +97,8 @@ var (
SessionDriverNotSupported = New("session driver [%s] not supported")
SessionNotFound = New("session [%s] not found")

UnknownFileExtension = New("unknown file extension")

ValidationDataInvalidType = New("data must be map[string]any or map[string][]string or struct")
ValidationDuplicateFilter = New("duplicate filter name: %s")
ValidationDuplicateRule = New("duplicate rule name: %s")
Expand Down
3 changes: 2 additions & 1 deletion support/docker/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/goravel/framework/contracts/database"
"github.com/goravel/framework/contracts/testing"
"github.com/goravel/framework/errors"
)

type MysqlImpl struct {
Expand Down Expand Up @@ -52,7 +53,7 @@ func (receiver *MysqlImpl) Build() error {
return fmt.Errorf("init Mysql docker error: %v", err)
}
if containerID == "" {
return fmt.Errorf("no container id return when creating Mysql docker")
return errors.DockerMissingContainerId.Args("Mysql")

Check warning on line 56 in support/docker/mysql.go

View check run for this annotation

Codecov / codecov/patch

support/docker/mysql.go#L56

Added line #L56 was not covered by tests
}

receiver.containerID = containerID
Expand Down
5 changes: 3 additions & 2 deletions support/file/file.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package file

import (
"errors"
"os"
"path/filepath"
"strings"
"time"

"github.com/gabriel-vasile/mimetype"

"github.com/goravel/framework/errors"
)

func ClientOriginalExtension(file string) string {
Expand Down Expand Up @@ -63,7 +64,7 @@ func Extension(file string, originalWhenUnknown ...bool) (string, error) {
}
}

return "", errors.New("unknown file extension")
return "", errors.UnknownFileExtension

Check warning on line 67 in support/file/file.go

View check run for this annotation

Codecov / codecov/patch

support/file/file.go#L67

Added line #L67 was not covered by tests
}

return strings.TrimPrefix(mtype.Extension(), "."), nil
Expand Down

0 comments on commit 0f04d58

Please sign in to comment.