feat: handle template build error

This commit is contained in:
2024-12-02 13:45:49 +00:00
parent 8a8582e06e
commit dc97c2c498
9 changed files with 123 additions and 11 deletions

17
main.go
View File

@@ -10,6 +10,7 @@ import (
"net/http"
"os"
"path/filepath"
"tesseract/internal/apierror"
"tesseract/internal/migration"
"tesseract/internal/service"
"tesseract/internal/template"
@@ -86,10 +87,20 @@ func main() {
c.Logger().Error(err)
_ = c.NoContent(http.StatusInternalServerError)
}
} else {
c.Logger().Error(err)
_ = c.NoContent(http.StatusInternalServerError)
return
}
var apiErr *apierror.APIError
if errors.As(err, &apiErr) {
if err = c.JSON(apiErr.StatusCode, apiErr); err != nil {
c.Logger().Error(err)
_ = c.NoContent(http.StatusInternalServerError)
}
return
}
c.Logger().Error(err)
_ = c.NoContent(http.StatusInternalServerError)
}
apiServer.Logger.Fatal(apiServer.Start(":8080"))