// Copyright 2014 beego Author. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package adapter import ( "net/http" "github.com/astaxie/beego/adapter/context" beecontext "github.com/astaxie/beego/server/web/context" "github.com/astaxie/beego/server/web" ) const ( errorTypeHandler = iota errorTypeController ) var tpl = ` beego application error
Request Method: {{.RequestMethod}}
Request URL: {{.RequestURL}}
RemoteAddr: {{.RemoteAddr }}
Stack
{{.Stack}}
` var errtpl = ` {{.Title}}
{{.Content}} Go Home

Powered by beego {{.BeegoVersion}}
` // ErrorMaps holds map of http handlers for each error string. // there is 10 kinds default error(40x and 50x) var ErrorMaps = web.ErrorMaps // ErrorHandler registers http.HandlerFunc to each http err code string. // usage: // beego.ErrorHandler("404",NotFound) // beego.ErrorHandler("500",InternalServerError) func ErrorHandler(code string, h http.HandlerFunc) *App { return (*App)(web.ErrorHandler(code, h)) } // ErrorController registers ControllerInterface to each http err code string. // usage: // beego.ErrorController(&controllers.ErrorController{}) func ErrorController(c ControllerInterface) *App { return (*App)(web.ErrorController(c)) } // Exception Write HttpStatus with errCode and Exec error handler if exist. func Exception(errCode uint64, ctx *context.Context) { web.Exception(errCode, (*beecontext.Context)(ctx)) }