Skip to content

Commit f2370fe

Browse files
committed
add IgnoreViewLoadError config
1 parent 6776bf0 commit f2370fe

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

configuration.go

+15
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ func NonBlocking() Configurator {
223223
}
224224
}
225225

226+
// IgnoreViewLoadError Server Runing, When View load has error will be ignore.
227+
func IgnoreViewLoadError() Configurator {
228+
return func(app *Application) {
229+
app.config.IgnoreViewLoadError = true
230+
}
231+
}
232+
226233
// WithoutServerError will cause to ignore the matched "errors"
227234
// from the main application's `Run/Listen` function.
228235
//
@@ -976,6 +983,9 @@ type Configuration struct {
976983
//
977984
// Defaults to empty map.
978985
Other map[string]interface{} `ini:"other" json:"other,omitempty" yaml:"Other" toml:"Other"`
986+
987+
// IgnoreViewLoadError Server Runing, When View load has error will be ignore
988+
IgnoreViewLoadError bool
979989
}
980990

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

1199+
// GetIgnoreViewLoadError returns the IgnoreViewLoadError field.
1200+
func (c *Configuration) GetIgnoreViewLoadError() bool {
1201+
return c.IgnoreViewLoadError
1202+
}
1203+
11891204
// WithConfiguration sets the "c" values to the framework's configurations.
11901205
//
11911206
// Usage:

iris.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@ func (app *Application) Build() error {
740740
app.view.AddFunc("urlpath", rv.Path)
741741
// app.view.AddFunc("url", rv.URL)
742742
if err := app.view.Load(); err != nil {
743-
return fmt.Errorf("build: view engine: %v", err)
743+
if app.config.IgnoreViewLoadError {
744+
app.logger.Errorf("build: view engine: %v", err)
745+
} else {
746+
return fmt.Errorf("build: view engine: %v", err)
747+
}
744748
}
745749
}
746750

0 commit comments

Comments
 (0)