Exceptions

By using exceptions we catch all unintended requests and handle them in a consistent way.

ErrorCodes

Error codes are defined as constants in \PhalconRest\Constants\ErrorCodes

Code Constant Status Code Message
1010 GENERAL_SYSTEM 500 General: System Error
1020 GENERAL_NOT_IMPLEMENTED 500 General: Not Implemented
1030 GENERAL_NOT_FOUND 404 General: Not Found
2010 AUTH_INVALID_ACCOUNT_TYPE 400 Authentication: Invalid Account Type
2020 AUTH_LOGIN_FAILED 401 Authentication: Login Failed
2030 AUTH_TOKEN_INVALID 401 Authentication: Token Invalid
2040 AUTH_SESSION_EXPIRED 401 Authentication: Session Expired
2050 AUTH_SESSION_INVALID 401 Authentication: Session Invalid
3010 ACCESS_DENIED 403 Access: Denied
4010 DATA_FAILED 500 Data: Failed
4020 DATA_NOT_FOUND 404 Data: Not Found

Outputting Errors

<?php

try {

    // Handle application

} catch (Exception $e) {

    $response = $di->get(Services::RESPONSE);

    $response->setErrorContent($e, true); // true enables debugMode (more error information)

}