fix: correctly handle errors from App constructor (#430)

Signed-off-by: mudler <mudler@mocaccino.org>
This commit is contained in:
Ettore Di Giacinto 2023-05-30 12:00:30 +02:00 committed by GitHub
parent ca9115d6d0
commit aacb96df7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/rs/zerolog/log"
)
func App(opts ...AppOption) *fiber.App {
func App(opts ...AppOption) (*fiber.App, error) {
options := newOptions(opts...)
zerolog.SetGlobalLevel(zerolog.InfoLevel)
@ -71,13 +71,13 @@ func App(opts ...AppOption) *fiber.App {
if options.preloadJSONModels != "" {
if err := ApplyGalleryFromString(options.loader.ModelPath, options.preloadJSONModels, cm); err != nil {
return nil
return nil, err
}
}
if options.preloadModelsFromPath != "" {
if err := ApplyGalleryFromFile(options.loader.ModelPath, options.preloadModelsFromPath, cm); err != nil {
return nil
return nil, err
}
}
@ -138,5 +138,5 @@ func App(opts ...AppOption) *fiber.App {
app.Get("/v1/models", listModels(options.loader, cm))
app.Get("/models", listModels(options.loader, cm))
return app
return app, nil
}