Added HTTP status codes to exception interceptors

This commit is contained in:
Marcin Kurczewski 2014-05-20 20:51:07 +02:00
parent 956283f4a0
commit bba35875a3
5 changed files with 29 additions and 18 deletions

View file

@ -39,6 +39,7 @@ class ApiController extends AbstractController
}
catch (Exception $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}

View file

@ -20,6 +20,7 @@ class AuthController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
$this->renderView('auth-login');
}

View file

@ -34,6 +34,7 @@ class PostController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}

View file

@ -93,6 +93,7 @@ class TagController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}
@ -119,6 +120,7 @@ class TagController extends AbstractController
}
catch (Exception $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}

View file

@ -53,6 +53,7 @@ class UserController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}
@ -106,6 +107,7 @@ class UserController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}
@ -132,6 +134,7 @@ class UserController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
$this->renderView('user-view');
}
@ -233,6 +236,7 @@ class UserController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}
@ -252,30 +256,31 @@ class UserController extends AbstractController
try
{
if (empty($tokenText))
{
Api::run(
new ActivateUserEmailJob(),
$this->appendUserIdentifierArgument([], $identifier));
if (empty($tokenText))
{
Api::run(
new ActivateUserEmailJob(),
$this->appendUserIdentifierArgument([], $identifier));
Messenger::success('Activation e-mail resent.');
}
else
{
$user = Api::run(new ActivateUserEmailJob(), [
JobArgs::ARG_TOKEN => $tokenText ]);
Messenger::success('Activation e-mail resent.');
}
else
{
$user = Api::run(new ActivateUserEmailJob(), [
JobArgs::ARG_TOKEN => $tokenText ]);
$message = 'Activation completed successfully.';
if (Core::getConfig()->registration->staffActivation)
$message .= ' However, your account still must be confirmed by staff.';
Messenger::success($message);
$message = 'Activation completed successfully.';
if (Core::getConfig()->registration->staffActivation)
$message .= ' However, your account still must be confirmed by staff.';
Messenger::success($message);
if (!Core::getConfig()->registration->staffActivation)
Auth::setCurrentUser($user);
}
if (!Core::getConfig()->registration->staffActivation)
Auth::setCurrentUser($user);
}
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}
@ -316,6 +321,7 @@ class UserController extends AbstractController
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
Messenger::fail($e->getMessage());
}