Add error pages, fix error handling and PHP conf

This commit is contained in:
Romain Neutron
2013-06-14 20:35:39 +02:00
parent 09c6361475
commit 42db38d055
140 changed files with 1962 additions and 1218 deletions

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -179,7 +180,7 @@ class API_OAuth2_Account
if (! $this->token) {
try {
$this->token = new API_OAuth2_Token($this->app['phraseanet.appbox'], $this);
} catch (Exception_NotFound $e) {
} catch (NotFoundHttpException $e) {
$this->token = API_OAuth2_Token::create($this->app['phraseanet.appbox'], $this);
}
}
@@ -263,7 +264,7 @@ class API_OAuth2_Account
$stmt->closeCursor();
if (! $row) {
throw new Exception_NotFound();
throw new NotFoundHttpException('Account nof found.');
}
return new self($app, $row['api_account_id']);

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -149,7 +150,7 @@ class API_OAuth2_Application
$stmt->execute(array(':application_id' => $this->id));
if (0 === $stmt->rowCount()) {
throw new \Exception_NotFound(sprintf('Application with id %d not found', $this->id));
throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id));
}
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -546,7 +547,7 @@ class API_OAuth2_Application
$stmt->closeCursor();
if ( ! $row)
throw new Exception_NotFound();
throw new NotFoundHttpException('Application not found.');
return new API_OAuth2_Account($this->app, $row['api_account_id']);
}
@@ -659,7 +660,7 @@ class API_OAuth2_Application
$stmt->closeCursor();
if ( ! $row)
throw new Exception_NotFound();
throw new NotFoundHttpException('Client not found.');
return new self($app, $row['application_id']);
}

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -44,7 +45,7 @@ class API_OAuth2_AuthCode
$stmt->closeCursor();
if ( ! $row)
throw new Exception_NotFound();
throw new NotFoundHttpException('Code not found');
$this->account_id = (int) $row['api_account_id'];
$this->redirect_uri = $row['redirect_uri'];

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -78,7 +79,7 @@ class API_OAuth2_Token
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ( ! $row)
throw new Exception_NotFound();
throw new NotFoundHttpException('Account not found');
$stmt->closeCursor();
@@ -286,7 +287,7 @@ class API_OAuth2_Token
$stmt->closeCursor();
if ( ! $row)
throw new Exception_NotFound();
throw new NotFoundHttpException('Account not found');
$account = new API_OAuth2_Account($app, $row['api_account_id']);

View File

@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Border\Manager as BorderManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -1190,7 +1191,7 @@ class API_V1_adapter extends API_V1_Abstract
try {
$record = $databox->get_record($record_id);
$result->set_datas(array('record' => $this->list_record($record)));
} catch (Exception_NotFound $e) {
} catch (NotFoundHttpException $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Record Not Found'));
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
@@ -1214,7 +1215,7 @@ class API_V1_adapter extends API_V1_Abstract
try {
$story = $databox->get_record($story_id);
$result->set_datas(array('story' => $this->list_story($story)));
} catch (Exception_NotFound $e) {
} catch (NotFoundHttpException $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found'));
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));