Skip to content

Commit

Permalink
chapter1-section4 errのスコープがおかしかったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
pikachu0310 committed Nov 19, 2023
1 parent e0447e4 commit 78ced8f
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 78ced8f

Please sign in to comment.