change SopRun to a variable
Showing
2 changed files
with
6 additions
and
2 deletions
| ... | @@ -24,6 +24,10 @@ import ( | ... | @@ -24,6 +24,10 @@ import ( |
| 24 | "github.com/astaxie/beego/session" | 24 | "github.com/astaxie/beego/session" |
| 25 | ) | 25 | ) |
| 26 | 26 | ||
| 27 | var ( | ||
| 28 | USERSTOPRUN = errors.New("User stop run") | ||
| 29 | ) | ||
| 30 | |||
| 27 | type Controller struct { | 31 | type Controller struct { |
| 28 | Ctx *context.Context | 32 | Ctx *context.Context |
| 29 | Data map[interface{}]interface{} | 33 | Data map[interface{}]interface{} |
| ... | @@ -181,7 +185,7 @@ func (c *Controller) Abort(code string) { | ... | @@ -181,7 +185,7 @@ func (c *Controller) Abort(code string) { |
| 181 | } | 185 | } |
| 182 | 186 | ||
| 183 | func (c *Controller) StopRun() { | 187 | func (c *Controller) StopRun() { |
| 184 | panic("StopRun") | 188 | panic(USERSTOPRUN) |
| 185 | } | 189 | } |
| 186 | 190 | ||
| 187 | func (c *Controller) UrlFor(endpoint string, values ...string) string { | 191 | func (c *Controller) UrlFor(endpoint string, values ...string) string { | ... | ... |
| ... | @@ -369,7 +369,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { | ... | @@ -369,7 +369,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { |
| 369 | func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) { | 369 | func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) { |
| 370 | defer func() { | 370 | defer func() { |
| 371 | if err := recover(); err != nil { | 371 | if err := recover(); err != nil { |
| 372 | if fmt.Sprint(err) == "StopRun" { | 372 | if err == USERSTOPRUN { |
| 373 | return | 373 | return |
| 374 | } | 374 | } |
| 375 | if _, ok := err.(middleware.HTTPException); ok { | 375 | if _, ok := err.(middleware.HTTPException); ok { | ... | ... |
-
Please register or sign in to post a comment