Skip to content

Commit

Permalink
Merge pull request #122 from traPtitech/fix/1-4-err-scope
Browse files Browse the repository at this point in the history
chapter1-section4 errのスコープがおかしかったのを修正
  • Loading branch information
pikachu0310 authored Nov 19, 2023
2 parents e0447e4 + 78ced8f commit e5737d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/chapter1/section4/src/practice_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func getCityInfoHandler(c echo.Context) error {
fmt.Println(cityName)

var city City
if err := db.Get(&city, "SELECT * FROM city WHERE Name=?", cityName); errors.Is(err, sql.ErrNoRows) {
err := db.Get(&city, "SELECT * FROM city WHERE Name=?", cityName)
if errors.Is(err, sql.ErrNoRows) {
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such city Name = %s", cityName))
}
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion docs/chapter1/section4/src/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func getCityInfoHandler(c echo.Context) error {
fmt.Println(cityName)

var city City
if err := db.Get(&city, "SELECT * FROM city WHERE Name=?", cityName); errors.Is(err, sql.ErrNoRows) {
err := db.Get(&city, "SELECT * FROM city WHERE Name=?", cityName)
if errors.Is(err, sql.ErrNoRows) {
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such city Name = %s", cityName))
}
if err != nil {
Expand Down

0 comments on commit e5737d6

Please sign in to comment.