Permalink
Browse files

Removed Error pages/modules - moved to a more generic dir - CustomPag…

…es; this pages could be customized by the app user
  • Loading branch information...
1 parent 1f7f513 commit ba9f7ebe65307ee04e703e1537a3cd8668f3d100 @fk1blow committed Jun 1, 2011
Showing with 216 additions and 0 deletions.
  1. +84 −0 lib/CustomPages/Error.js
  2. +32 −0 lib/CustomPages/ErrorHandler.js
  3. +100 −0 lib/CustomPages/errorTemplate.html.ejs
View
84 lib/CustomPages/Error.js
@@ -0,0 +1,84 @@
+function cl(o) {
+ console.log(o);
+}
+
+
+/**
+ * Error object
+ *
+ * - should make an object defining the section of the modules where the error has occured
+ * - this class should be called from everywhere within the framework
+ */
+Module('Seek', function() {
+
+ Class('Errors', {
+ my: {
+ has: {
+ errors: {
+ init: null
+ },
+
+ section: {
+ init: null
+ },
+
+ types: {
+ init: ['not_defined', 'non_object_property_load', 'non_object_property_call']
+ }
+ },
+
+ methods: {
+ add: function(err_object) {
+ this.errors = err_object;
+ this.errors.headers = err_object.headers || 500;
+ },
+
+ retrieve: function() {
+ return this.errors;
+ },
+
+ reset: function() {
+ this.errors = null;
+ },
+
+ handleErrors: function() {
+ Seek.HandleError.renderError(this.errors);
+ this.reset();
+ },
+
+ hasErrors: function() {
+ return (this.errors == null) ? false : true;
+ }
+ }
+ }
+ });
+
+
+ Class('HandleError', {
+ my: {
+ has: {
+ handle_error_output: {
+ init: 'view'
+ }
+ },
+
+ methods: {
+ renderError: function(errors) {
+ Seek.View.Base.renderExtraView('errorTemplate.html.ejs',
+ __dirname + '/../Error/', {
+ title: errors.error_object,
+ error_stack_message: errors.error_object,
+ error_stack: errors.error_object.stack.replace(errors.error_object, '').split(/\n/i),
+ request_object: {
+ url: Seek.URL.Request.getUrl(),
+ params: Seek.ActionModule.ActionRouter.getParams()
+ },
+ controller: 'someController',
+ action: 'someAction'
+ }, null, 500);
+ }
+ }
+ }
+ });
+
+});
View
32 lib/CustomPages/ErrorHandler.js
@@ -0,0 +1,32 @@
+Module('Seek', function() {
+
+ Class('ErrorHandler', {
+ my: {
+ has: {
+ handle_error_output: {
+ init: 'view'
+ },
+
+ error_template_path: {
+ init: __dirname + '/../Error/'
+ },
+
+ error_template_file: {
+ init: 'errorTemplate.html.ejs'
+ }
+ },
+
+ methods: {
+ renderError: function() {
+ Seek.View.Base.renderExtraView(this.error_template_file, {
+ error_object: err,
+ request: Seek.URL.Request.getRequest(),
+ router_object: Seek.ActiveDispatcher.Router.getCurrentRoute(),
+ params: Seek.ActionModule.ActionRouter.getParams()
+ }, this.error_template);
+ }
+ }
+ }
+ });
+
+});
View
100 lib/CustomPages/errorTemplate.html.ejs
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>Error:: {error_type, error_header}</title>
+ <style>
+ * {
+ font-family:Arial, Verdana, sans-serif;
+ font-size:1em;
+ }
+
+ body {
+ padding:0 10px 10px;
+ margin:0;
+ background-color:#F2F2F2;
+ color:#000;
+ }
+
+ h1, h4, p {
+ padding:0;
+ margin:0;
+ }
+
+
+ h1 {
+ font-size:26px;
+ font-weight:normal;
+ line-height:60px;
+ color:#000;
+ }
+
+
+ div.section {
+ color:#fff;
+ padding:10px;
+ margin-bottom:20px;
+ background-color:#9B9B9B;
+ }
+ div.section h4 {
+ font-size:18px;
+ color:#000;
+ margin-bottom:10px;
+ }
+ div.section p {
+ padding:10px;
+ background-color:#000;
+ color:#EAE8E8;
+ font-size:13px;
+ }
+
+ ul {
+ list-style-type:none;
+ padding:10px;
+ background-color:#000;
+ color:#EAE8E8;
+ font-size:13px;
+ }
+ ul li {
+ line-height:18px;
+ }
+ </style>
+</head>
+<body>
+ <h1>
+ <%= @title %>
+ </h1>
+
+
+ <!-- Response status -->
+ <div class="section">
+ <h4>Response status</h4>
+ <p style="color:#E52424; font-size:16px;"><b>500</b></p>
+ </div>
+ <!-- Response status -->
+
+
+ <!-- Error trace -->
+ <div class="section">
+ <h4>Framework Stack Trace</h4>
+ <ul style="margin-bottom:0;">
+ <% for item in @error_stack: %>
+ <li><%= item %></li>
+ <% end %>
+ </ul>
+ </div>
+ <!-- /Error trace -->
+
+
+ <!-- Request object -->
+ <div class="section">
+ <h4>Request object</h4>
+ <ul style="margin-bottom:0;">
+ <li><b>url</b>: <%= @request_object.url %></li>
+ <li><b>params</b>: <%= JSON.stringify(@request_object.params) %></li>
+ <li><b>controller</b>: <%= @controller %></li>
+ <li><b>action</b>: <%= @action %></li>
+ </ul>
+ </div>
+ <!-- /Request object -->
+</body>
+</html>

0 comments on commit ba9f7eb

Please sign in to comment.