Skip to content

Commit

Permalink
Error handler tweaks, closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
darsain committed Dec 23, 2013
1 parent 4b551c7 commit c1364da
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
21 changes: 0 additions & 21 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,6 @@ jQuery(function ($) {

$controls.html(tmpl('controls_loading'));
execution.then(responseDone, responseFail);
/*
execution.done(function (res) {
console.log('done response:', res);
$response.show();
if (res && res.output !== undefined) {
$controls.html(tmpl('controls', res));
$response.html(tmpl('output', res));
activate(tabs.active, 1);
} else {
$controls.html(tmpl('ended_unexpectedly'));
$response.html(tmpl('output', res));
activate(tabs.initial, 1);
}
}).fail(function (res) {
console.log('fail response:', res);
$controls.html(tmpl('controls_error', res));
$response.html(tmpl('output', res.responseText));
}).always(function () {
$response.imagesLoaded(resize);
});*/
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Darsain/Console/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function execute($code)
$output = ob_get_contents();
ob_end_clean();

// Retrieve an error
// When error occurred, add it to profile.
if ($estatus === false) {
static::addProfile('error', error_get_last());
}
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/ConsoleController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Darsain\Console;

use \Controller, \View, \Input, \App, \Response, \Route;
use \Controller, \View, \Input, \Response;

class ConsoleController extends Controller {

Expand All @@ -16,6 +16,11 @@ public function postExecute()
// Execute and profile the code
$profile = Console::execute($code);

// Terminate on error, as Error Handler already responded.
if (isset($profile['error']) and $profile['error']) {
exit;
}

// Response
return Response::json($profile);
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

App::error(function (Exception $e, $code) {
if (Route::currentRouteName() !== 'console_execute') {
if (App::runningInConsole() or !(Request::url() === 'console' and $_SERVER['REQUEST_METHOD'] === 'POST')) {
return;
}
@ob_end_clean();
Expand Down
2 changes: 1 addition & 1 deletion src/views/partials/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<pre class="output_holder">{{=output}}</pre>
{{ } else if (typeof data !== 'undefined' && data) { }}
{{=data}}
{{ } else if (!error) { }}
{{ } else if (typeof error === 'undefined') { }}
<span class="muted"><em>Code produced no output</em></span>
{{ } }}

Expand Down

0 comments on commit c1364da

Please sign in to comment.