Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IgnoreViewLoadError config #2482

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ func NonBlocking() Configurator {
}
}

// IgnoreViewLoadError Server Runing, When View load has error will be ignore.
func IgnoreViewLoadError() Configurator {
return func(app *Application) {
app.config.IgnoreViewLoadError = true
}
}

// WithoutServerError will cause to ignore the matched "errors"
// from the main application's `Run/Listen` function.
//
Expand Down Expand Up @@ -976,6 +983,9 @@ type Configuration struct {
//
// Defaults to empty map.
Other map[string]interface{} `ini:"other" json:"other,omitempty" yaml:"Other" toml:"Other"`

// IgnoreViewLoadError Server Runing, When View load has error will be ignore
IgnoreViewLoadError bool
}

var _ context.ConfigurationReadOnly = (*Configuration)(nil)
Expand Down Expand Up @@ -1186,6 +1196,11 @@ func (c *Configuration) GetOther() map[string]interface{} {
return c.Other
}

// GetIgnoreViewLoadError returns the IgnoreViewLoadError field.
func (c *Configuration) GetIgnoreViewLoadError() bool {
return c.IgnoreViewLoadError
}

// WithConfiguration sets the "c" values to the framework's configurations.
//
// Usage:
Expand Down
6 changes: 5 additions & 1 deletion iris.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,11 @@ func (app *Application) Build() error {
app.view.AddFunc("urlpath", rv.Path)
// app.view.AddFunc("url", rv.URL)
if err := app.view.Load(); err != nil {
return fmt.Errorf("build: view engine: %v", err)
if app.config.IgnoreViewLoadError {
app.logger.Errorf("build: view engine: %v", err)
} else {
return fmt.Errorf("build: view engine: %v", err)
}
}
}

Expand Down
Loading