Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hayato24s committed Mar 18, 2024
1 parent a894aac commit 9cd0e38
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 13 deletions.
2 changes: 0 additions & 2 deletions codegen/error/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
("ModuleNotFound", NotFound),
],
"shared": [
("AlreadyExists", AlreadyExists),
("InvalidArgument", InvalidArgument),
("NotFound", NotFound),
("Unauthenticated", Unauthenticated),
("Unauthorized", PermissionDenied),
],
Expand Down
6 changes: 3 additions & 3 deletions handler/api/rest/v3/course.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package restv3
import (
"context"
"fmt"
"net/http"
"strconv"
"strings"

"github.com/twin-te/twinte-back/apperr"
"github.com/labstack/echo/v4"
"github.com/twin-te/twinte-back/base"
"github.com/twin-te/twinte-back/handler/api/rest/v3/openapi"
shareddomain "github.com/twin-te/twinte-back/module/shared/domain"
sharederr "github.com/twin-te/twinte-back/module/shared/err"
timetablemodule "github.com/twin-te/twinte-back/module/timetable"
timetabledomain "github.com/twin-te/twinte-back/module/timetable/domain"
)
Expand Down Expand Up @@ -328,7 +328,7 @@ func (h *impl) GetCoursesYearCode(ctx context.Context, request openapi.GetCourse
}

if len(courses) == 0 {
return nil, apperr.New(sharederr.CodeNotFound, "")
return nil, echo.NewHTTPError(http.StatusNotFound, "not found course")
}

apiCourse, err := toApiCourse(courses[0])
Expand Down
2 changes: 0 additions & 2 deletions handler/common/interceptor/error_code_map_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions handler/common/middleware/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ func NewEchoErrorHandler() func(echo.HandlerFunc) echo.HandlerFunc {

if aerr, ok := apperr.As(err); ok {
switch aerr.Code {
case sharederr.CodeAlreadyExists:
return echo.NewHTTPError(http.StatusConflict, aerr.Message)
case sharederr.CodeInvalidArgument:
return echo.NewHTTPError(http.StatusBadRequest, aerr.Message)
case sharederr.CodeUnauthenticated:
return echo.ErrUnauthorized
case sharederr.CodeUnauthorized:
return echo.ErrForbidden
case sharederr.CodeNotFound:
return echo.NewHTTPError(http.StatusNotFound, aerr.Message)
}
}

Expand Down
2 changes: 0 additions & 2 deletions module/shared/err/code_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9cd0e38

Please sign in to comment.