thinkjs/template/controller/es6_error.js
2015-08-24 18:09:49 +08:00

45 lines
896 B
JavaScript

'use strict';
/**
* error controller
*/
export default class extends think.controller.base {
/**
* display error page
* @param {Number} status []
* @return {Promise} []
*/
displayErrorPage(status){
var file = `common/error/${status}.html`;
var options = this.config('tpl');
options = think.extend({}, options, {type: 'ejs'});
return this.display(file, options);
}
/**
* Forbidden
* @return {Promise} []
*/
_403Action(){
return this.displayErrorPage(403);
}
/**
* Not Found
* @return {Promise} []
*/
_404Action(){
return this.displayErrorPage(404);
}
/**
* Internal Server Error
* @return {Promise} []
*/
_500Action(){
return this.displayErrorPage(500);
}
/**
* Service Unavailable
* @return {Promise} []
*/
_503Action(){
return this.displayErrorPage(503);
}
}