Exemplo n.º 1
0
/**
 * @internal
 *
 * Mango Framework uncaught exception handler
 *
 * Default Exception handler for mango. This gets called by the system
 * every time there is an uncaught exception thrown.
 *
 * @param Exception	$exception	The exception thrown
 *
 * @return void
 */
function mango_exception_handler($exception)
{
    if (!MAppDelegate()->didRecoverFromUncaughtException($exception)) {
        logException($exception);
        if (!isRunningFromCommandLine() || isRunningInSimulatedRequestMode()) {
            $response = new MHTTPViewControllerResponse(new MErrorViewController(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR, N(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR), S("Internal Server Error"), S("Sorry but the page you are looking for could not be loaded due to an internal server error")));
            $response->setCode(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR);
            MDie($response);
        } else {
            MDie(null, 1);
        }
    }
}
Exemplo n.º 2
0
/**
 * Kills the current application and returns $response to the client
 *
 * This function responds to the client using an instance of HTTPResponse
 * specified by $response and kills the execution of the application
 * imediately after.
 *
 * @see MHTTPResponse
 *
 * @param MHTTPResponse $response The HTTP response to return to the client
 * before killing the application
 *
 * @return void
 */
function MDie(MHTTPResponse $response = null, $returnCode = 0)
{
    MAssertTypes('int', $returnCode);
    MAppDelegate()->willTerminateWithResponse($response, $returnCode);
    if (!is_null($response)) {
        MSendResponse($response);
    }
    die($returnCode);
}