From 7b27b7fed0eabd499a1870d1a70f7bdde6fab090 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 17 Dec 2013 08:53:15 +0800 Subject: [PATCH] change SopRun to a variable --- controller.go | 6 +++++- router.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/controller.go b/controller.go index b3b3577f..13f358be 100644 --- a/controller.go +++ b/controller.go @@ -24,6 +24,10 @@ import ( "github.com/astaxie/beego/session" ) +var ( + USERSTOPRUN = errors.New("User stop run") +) + type Controller struct { Ctx *context.Context Data map[interface{}]interface{} @@ -181,7 +185,7 @@ func (c *Controller) Abort(code string) { } func (c *Controller) StopRun() { - panic("StopRun") + panic(USERSTOPRUN) } func (c *Controller) UrlFor(endpoint string, values ...string) string { diff --git a/router.go b/router.go index 2bc14a87..df7f5a19 100644 --- a/router.go +++ b/router.go @@ -369,7 +369,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { - if fmt.Sprint(err) == "StopRun" { + if err == USERSTOPRUN { return } if _, ok := err.(middleware.HTTPException); ok {