Greg Slepak avatar Greg Slepak committed 0ef5106

finished the dragonfly_errors page and improved the 404/500 pages.

Comments (0)

Files changed (5)

example-site/dragonfly-framework/plugins-active/dragonfly_basic.lsp

 		<div id="%s">&nbsp;</div>
 		<script type="text/javascript">
 			(function fetcher() {
-				var id = '#' + '%s';
+				var div = $('#' + '%s');
 				var load_text = 'loading...';
 				setTimeout(function() {
 					if (load_text)
-						$(id).html(load_text);
+						div.html(load_text);
 				}, 1000);
 				$.ajax({
 					url: "%s",
 					timeout: 10000,
 					success: function (data, status) {
 						load_text = null;
-						$(id).html(data);
+						div.html(data);
 						setTimeout(fetcher, %d);
 					},
 					error: function (xmlReq, status, error) {
 						load_text = null;
-						$(id).html('error code: ' + xmlReq.status + '<br/>' +
+						div.html('error code: ' + xmlReq.status + '<br/>' +
 					 	           'error message: ' + error + '<br/>' +
 						           'attempting to load: ' + this.url);
 						setTimeout(fetcher, %d);

example-site/includes/css/screen.css

 		margin-top: 10px;
 		background-color: #EEE;
 	}
-
+	
+	#content div#demo-error {
+		border: 1px solid #999;
+		margin: 15px 0px;
+		padding: 15px;
+	}
+	
+	#content div#demo-error h1 {
+		font-size: 16px;
+	}
+	
 	/* Paragraph styles */
 	
 	#content p {

example-site/views/404.html

 <body>
   <div class="dialog">
     <h1>We're sorry, but something went wrong. (404)</h1>
-    <p>We couldn't find the page or file you asked for. Start over right <a href="./">here</a>.</p>
+    <p>We couldn't find the page or file you asked for.</p>
+	<p>Start over <a href="./">here</a> or <a href="javascript:history.back();">go back</a>.</p>
   </div>
 </body>
 </html>

example-site/views/500.html

 <body>
   <div class="dialog">
     <h1>We're sorry, but something went wrong.</h1>
-    <p>We've been notified about this issue and we'll take a look at it shortly. Start over right <a href="./">here</a>.</p>
+    <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+	<p>Start over <a href="./">here</a> or <a href="javascript:history.back();">go back</a>.</p>
 	<div class="backtrace">
 		<%=(join (parse (last (last-error)) "\n") "<br/>")%>
 	</div>

example-site/views/dragonfly_errors.html

 		</div>
 		
 		<h1>Handling Errors</h1>
-		<p class="extract">blah blah blah</p>
-
 		<p>
-			blahbity blah blah blah
+			What happens when a user visits the following link?
 		</p>
+		<p>
+			<a href="<%=(setf *link* (web-root "bar" (find "newLISP" SERVER_SOFTWARE)))%>"><%=(string "http://" HTTP_HOST *link*)%></a>
+		</p>
+		<p>
+			Go ahead and click it. I can wait.
+		</p>
+		<p>Back already?</p>
+		<p>
+			That was an error 404 page, the page that's displayed when all routes failed to match.
+		</p>
+		<h3>Generating Errors</h3>
+		<p>
+			Dragonfly uses the <span class="code">DF:display-error</span> function to show these pages. You can too! Here's a quick example of how to use it:
+		</p>
+		<pre class="code">(display-error 500)</pre>
+		<p>
+			Pretty simple huh?
+		</p>
+		<h3>The <span class="code" style="font-size:inherit">ERROR_TEMPLATE</span></h3>
+		<p>
+			By default Dragonfly does not show that fancy page you just saw, instead it stores a default (and boring) error template in the symbol <span class="code">DF:ERROR_TEMPLATE</span>, which it will use to display all errors if it can't find an alternative:
+		</p>
+		<div id="demo-error">
+			<%
+				(Response:status 404)
+				(eval-template ERROR_TEMPLATE)
+			    (Response:status 200)
+			%>
+		</div>
+		<p>
+			How do you specify an alternative?
+		</p>
+		<h3>Custom Error Templates</h3>
+		<p>
+			Dragonfly will check inside <span class="code">VIEW_PATHS</span> to see if a view with the error number exists. In other words, a call to <span class="code">(display-error 500)</span> results in a check for:
+		</p>
+		<pre class="code">(file? (Dragonfly:view-path "500"))</pre>
+		<p>
+			If it exists, it will be displayed instead of <span class="code">ERROR_TEMPLATE</span>.
+		</p>
+		<p>
+			Want to see the 500 template this site uses?
+		</p>
+		<p><a href="<%=(web-root "wings/3" (find "newLISP" SERVER_SOFTWARE))%>">I thought you'd never ask.</a></p>
 		
+		<h3>Checking the <span class="code" style="font-size:inherit">dragonfly.log</span></h3>
+		
+		<p>
+			Dragonfly defines an error handler <span class="code">DF:error-handler</span>, that's called whenever an error is generated (for example, by a call to <span class="code">throw-error</span>). You can specify your own handler with a <%(link_to "plugin" "dragonfly_plugins")%>.
+		</p>
+		<p>
+			The default handler makes use of Dragonfly's logging functions to log the stack-trace to the file specified by <span class="code">LOG_FILE_PATH</span> in <b>config.lsp</b>, and then it will call <span class="code">(display-error 500)</span>.
+		</p>
+		<p>
+			If you don't want to publicly show the stack trace in your error 500 template, you don't have to. Just remember to check the log for it. You'll probably also want to setup a <a href="http://en.wikipedia.org/wiki/Cron">cron</a> script roll over the log every now and then to prevent it from getting too large.
+		</p>
+		<p>
+			Dragonfly's logging facilities are defined <b>dragonfly-framework/lib/log.lsp</b>, check <%(link_to "the api" "dragonfly_api")%> for more info.
+		</p>
 		
 		<% (display-partial "continue") %>
 		
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.