Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
26130a5d
Commit
26130a5d
authored
Mar 30, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #1073
parent
2c9363d2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
17 deletions
+9
-17
error.go
error.go
+6
-6
router.go
router.go
+3
-11
No files found.
error.go
View file @
26130a5d
...
...
@@ -439,24 +439,26 @@ func exception(errcode string, ctx *context.Context) {
if
err
!=
nil
{
code
=
503
}
ctx
.
ResponseWriter
.
WriteHeader
(
code
)
if
h
,
ok
:=
ErrorMaps
[
errcode
];
ok
{
executeError
(
h
,
ctx
)
executeError
(
h
,
ctx
,
code
)
return
}
else
if
h
,
ok
:=
ErrorMaps
[
"503"
];
ok
{
executeError
(
h
,
ctx
)
executeError
(
h
,
ctx
,
code
)
return
}
else
{
ctx
.
ResponseWriter
.
WriteHeader
(
code
)
ctx
.
WriteString
(
errcode
)
}
}
func
executeError
(
err
*
errorInfo
,
ctx
*
context
.
Context
)
{
func
executeError
(
err
*
errorInfo
,
ctx
*
context
.
Context
,
code
int
)
{
if
err
.
errorType
==
errorTypeHandler
{
ctx
.
ResponseWriter
.
WriteHeader
(
code
)
err
.
handler
(
ctx
.
ResponseWriter
,
ctx
.
Request
)
return
}
if
err
.
errorType
==
errorTypeController
{
ctx
.
Output
.
SetStatus
(
code
)
//Invoke the request handler
vc
:=
reflect
.
New
(
err
.
controllerType
)
execController
,
ok
:=
vc
.
Interface
()
.
(
ControllerInterface
)
...
...
@@ -476,13 +478,11 @@ func executeError(err *errorInfo, ctx *context.Context) {
method
.
Call
(
in
)
//render template
if
ctx
.
Output
.
Status
==
0
{
if
AutoRender
{
if
err
:=
execController
.
Render
();
err
!=
nil
{
panic
(
err
)
}
}
}
// finish all runrouter. release resource
execController
.
Finish
()
...
...
router.go
View file @
26130a5d
...
...
@@ -862,8 +862,8 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) {
panic
(
err
)
}
else
{
if
ErrorsShow
{
if
handler
,
ok
:=
ErrorMaps
[
fmt
.
Sprint
(
err
)];
ok
{
ex
ecuteError
(
handler
,
context
)
if
_
,
ok
:=
ErrorMaps
[
fmt
.
Sprint
(
err
)];
ok
{
ex
ception
(
fmt
.
Sprint
(
err
)
,
context
)
return
}
}
...
...
@@ -886,15 +886,7 @@ func (p *ControllerRegistor) recoverPanic(context *beecontext.Context) {
}
else
{
// in production model show all infomation
if
ErrorsShow
{
if
handler
,
ok
:=
ErrorMaps
[
fmt
.
Sprint
(
err
)];
ok
{
executeError
(
handler
,
context
)
return
}
else
if
handler
,
ok
:=
ErrorMaps
[
"503"
];
ok
{
executeError
(
handler
,
context
)
return
}
else
{
context
.
WriteString
(
fmt
.
Sprint
(
err
))
}
exception
(
fmt
.
Sprint
(
err
),
context
)
}
else
{
Critical
(
"the request url is "
,
context
.
Input
.
Url
())
Critical
(
"Handler crashed with error"
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment