function cleanup() { $err = error_get_last(); if ($err !== null && $err["type"] == E_ERROR) { ob_end_clean(); $response = new ErrorResponse(); $response->render(); } }
public function __construct($token) { if ($token) { $this->setInfo('token', $token); } parent::__construct(); }
public function __construct($plugin_key = null) { if ($plugin_key) { $this->setInfo('plugin_id', $plugin_key); } parent::__construct(); }
public function __construct($userId, $token) { parent::__construct(); if ($userId) { $this->setInfo('userId', $userId); } if ($token) { $this->setInfo('token', $token); } }
public function __construct($type = null, $name = null) { if ($type) { $this->setInfo('type', $type, true); } if ($name) { $this->setInfo('name', $name); } parent::__construct(); }
public function __construct($clientId, $clientSecret) { if ($clientId) { $this->setInfo('client_id', $clientId); } if ($clientSecret) { $this->setInfo('client_secret', $clientSecret); } parent::__construct(); }
public function __construct($type = null, $key = null) { if ($type) { $this->setInfo('type', $type, true); } if ($key) { $this->setInfo('key', $key, true); } parent::__construct(); }
public function __construct($_token = null) { parent::__construct(); if ($_token) { $token = explode('Bearer ', $_token); if (sizeof($token) > 1) { $this->setInfo('token', $token[1]); } else { $this->setInfo('token', $_token); } } }
public function __construct($file = null, $line = null, $message = null) { if ($file) { $this->setInfo('file', $file); } if ($line) { $this->setInfo('line', $line); } if ($message) { $this->setInfo('message', $message); } parent::__construct(); }
public function HandleError($errNo, $errStr, $errFile, $errLine, $errContext) { if (!isset($_REQUEST['typ'])) { $_REQUEST['typ'] = 'html'; } $debug_str = '<ul>'; foreach (debug_backtrace() as $debug) { if ($debug['class'] != '') { $debug_str = '<li>' . $debug['file'] . ' (' . $debug['line'] . '): ' . $debug['class'] . '::' . $debug['function'] . '()</li>' . $debug_str; } else { $debug_str = '<li>' . $debug['file'] . ' (' . $debug['line'] . '): ' . $debug['function'] . '()</li>' . $debug_str; } } $debug_str .= '</ul>'; $errType = $this->mErrorType[$errNo]; // adding error info into $GLOBALS $GLOBALS['error_info'] = array('errtype' => $errType, 'errstr' => $errStr, 'errfile' => $errFile, 'errline' => $errLine, 'errcontext' => $errContext, 'debugstr' => $debug_str); require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/gtfw/response/ResponseIntf.class.php'; require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/gtfw/response/' . $_REQUEST['typ'] . '/' . ucfirst($_REQUEST['typ']) . 'Response.class.php'; require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/gtfw/response/' . $_REQUEST['typ'] . '/ErrorResponse.class.php'; $error_response = new ErrorResponse(); $error_response->Send(); die; }
public function __construct($username, $passwordLength) { if ($username) { $this->setInfo('username', $username); } if ($passwordLength) { $hiddenPassword = ''; if ($passwordLength < 20) { for ($i = 0; $i < $passwordLength; $i++) { $hiddenPassword .= '*'; } } $this->setInfo('password', $hiddenPassword); } parent::__construct(); }
public function __construct($resourceType = null, $resourceKey = null, $username = null, $permission = null) { if ($username) { $this->setInfo('username', $username); } if ($resourceType) { $this->setInfo('resourceType', $resourceType); } if ($resourceKey) { $this->setInfo('resourceKey', $resourceKey); } if ($permission) { $this->setInfo('permission', $permission); } parent::__construct(); }
/** * Should be in the format (all required): * static $SAMPLE_ERROR_KEY = array( * 'message' => 'sample error message', * 'httpcode' => '401', * 'code' => 1); // optional */ function __construct() { $rClass = new \ReflectionClass(get_called_class()); $rProperties = $rClass->getProperties(\ReflectionProperty::IS_STATIC); $defaultProps = $rClass->getDefaultProperties(); foreach ($rProperties as $rProperty) { $ignoreAnnotation = ReflectionHelper::getDocDirective($rProperty->getDocComment(), 'ignore'); if (!empty($ignoreAnnotation) || !is_array($defaultProps[$rProperty->getName()]) || empty($defaultProps[$rProperty->getName()])) { continue; } $propertyKeys = array_keys($defaultProps[$rProperty->getName()]); $key = $propertyKeys[0]; $errorResponseArray = $defaultProps[$rProperty->getName()][$key]; if (empty($errorResponseArray['message']) || empty($errorResponseArray['httpcode'])) { continue; } $this->errorResponses[$key] = ErrorResponse::FromArray($errorResponseArray); } }
public function __construct($reason = null, $info = null, $errstring = null) { switch ($reason) { case 'url': $this->setInfo('reason', 'url', true); $this->setInfo('url', '"' . $info . '"'); break; case 'parse': $this->setInfo('reason', 'parse', true); $this->setInfo('line', $info, true); $this->setInfo('errstring', '"' . $errstring . '"', true); break; case 'field': $this->setInfo('reason', 'field', true); $this->setInfo('field', $info, true); $this->setInfo('errstring', '"' . $errstring . '"', true); break; } parent::__construct(); }
public function __construct(Request $request) { parent::__construct($request, ResponseCodes::HTTP_BAD_REQUEST, ResponseCodes::getMessageForCode(ResponseCodes::HTTP_BAD_REQUEST)); }
public function __construct($plugin_key, $username) { $this->setInfo('pluginKey', $plugin_key, true); $this->setInfo('username', $username, true); parent::__construct(); }
function handle($request) { $this->request = $request; // // Set up to catch responses that drop outof the sky // ErrorHandler::setRequest($request); ErrorHandler::handleFatalErrors(function ($response) { $this->onErrorResponseFromHandlers($response); }); ErrorHandler::handleScriptErrors(function ($response) { $this->onErrorResponseFromHandlers($response); }); // ErrorHandler::handleExceptions(function($response){ $this->onErrorResponseFromHandlers($response); }); try { $this->doSetUp(); try { $this->doSomething(); $returnedValues = "good response"; $response = new GoodResponse($this->request, $returnedVlaues); // // Here make the doSomething response into a FULL response // } catch (Exception $exception) { $response = ErrorResponse::fromException($exception); var_dump($response); } } catch (\Exception $exception) { $response = "outter catch block"; //sendResponse($response); } $this->sendResponse($response); }
public function __construct() { parent::__construct(); }
public function __construct($field) { $this->setInfo('field', $field, true); parent::__construct(); }
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: accept, authorization, content-type"); header("Access-Control-Allow-Methods: PUT, DELETE, POST, GET, OPTIONS"); // Store request method $method = $_SERVER['REQUEST_METHOD']; // Store path if (array_key_exists("PATH_INFO", $_SERVER)) { $path = explode('/', $_SERVER['PATH_INFO']); $path = trimPath($path, 1); } else { $path = array(); } // Store payload - JSON that is sent with the request $payload = file_get_contents('php://input'); if ($payload) { $body = json_decode($payload, true); } else { $body = array(); } // If there are no errors in the JSON, instantiate MainController if (json_last_error() == JSON_ERROR_NONE) { $req = new MainController($path, $method, $body); $response = $req->getResponse(); } else { $response = new ErrorResponse(new InvalidJSONError($payload)); } // Set content type and response code for the result header($response->getContentType()); http_response_code($response->getResponseCode()); // Print the JSON result of request echo $response->getBody();
public function __construct(Request $request) { parent::__construct($request, ResponseCodes::HTTP_FORBIDDEN, ResponseCodes::getMessageForCode(ResponseCodes::HTTP_FORBIDDEN)); }
public function __construct(Request $request, $methodsAllowed) { parent::__construct($request, ResponseCodes::HTTP_METHOD_NOT_ALLOWED, ResponseCodes::getMessageForCode(ResponseCodes::HTTP_METHOD_NOT_ALLOWED)); $this->addHeader('Allow: ' . implode(', ', $methodsAllowed)); }
public function __construct(Request $request) { parent::__construct($request, ResponseCodes::HTTP_INTERNAL_SERVER_ERROR, ResponseCodes::getMessageForCode(ResponseCodes::HTTP_INTERNAL_SERVER_ERROR)); }
public function __construct(Request $request) { parent::__construct($request, ResponseCodes::HTTP_NOT_IMPLEMENTED, ResponseCodes::getMessageForCode(ResponseCodes::HTTP_NOT_IMPLEMENTED)); }
public function __construct($scope) { $this->setInfo('scope', $scope, true); parent::__construct(); }
/** * This public function makes a transaction status request * * @param string $transactionId The transaction ID to query. (as returned from the TX request) * @return An instance of AcquirerStatusResponse or FALSE on failure. */ function RequestTransactionStatus( $transactionId ) { $this->clearError(); $configCheck = $this->CheckConfig($this->config); if ($configCheck != "OK") { $errorResponse = new ErrorResponse(); $errorResponse->setErrorCode("001"); $errorResponse->setErrorMessage("Config error: ".$configCheck); $errorResponse->setConsumerMessage(""); return $errorResponse; } //check TransactionId length $transactionIdOK = $this->LengthCheck("TransactionID", $transactionId, "16"); if ($transactionIdOK != "ok") { return $this->getError(); } if ( ! $this->verifyNotNull( $transactionId, "transactionId" ) ) { $errorResponse = $this->getError(); return $errorResponse; } // Build the status request XML. $xmlMsg = $this->getXMLHeader( "AcquirerStatusReq", null, null, $transactionId, null ); if ( ! $xmlMsg ) { return false; } // Add transaction information. $xmlMsg .= "<Transaction>\n<transactionID>" . $transactionId . "</transactionID></Transaction>\n"; $xmlMsg .= "</AcquirerStatusReq>\n"; // Post the request to the server. $response = $this->PostXMLData( $xmlMsg ); if ($this->parseFromXml( "errorCode", $response ) != "") { $errorResponse = new ErrorResponse(); $errorResponse->setErrorCode($this->parseFromXml( "errorCode", $response )); $errorResponse->setErrorMessage($this->parseFromXml( "errorMessage", $response )); $errorResponse->setConsumerMessage($this->parseFromXml( "consumerMessage", $response )); return $errorResponse; } if ( ($this->parseFromXml( "acquirerID", $response ) == "") || (!$response )) { $errorResponse = new ErrorResponse(); $errorResponse->setErrorCode("ING1001"); $errorResponse->setErrorMessage("Status lookup mislukt (aquirer side)"); $errorResponse->setConsumerMessage(""); return $errorResponse; } // Build the status response object and pass the data into it. $res = new AcquirerStatusResponse(); $creationTime = $this->parseFromXml( "createDateTimeStamp", $response ); $res->setAcquirerID( $this->parseFromXml( "acquirerID", $response ) ); $res->setConsumerName( $this->parseFromXml( "consumerName", $response ) ); $res->setConsumerAccountNumber( $this->parseFromXml( "consumerAccountNumber", $response ) ); $res->setConsumerCity( $this->parseFromXml( "consumerCity", $response ) ); $res->setTransactionID( $this->parseFromXml( "transactionID", $response ) ); // The initial status is INVALID, so that future modifications to // this or remote code will yield alarming conditions. $res->setStatus(IDEAL_TX_STATUS_INVALID ); $status = $this->parseFromXml( "status", $response ); // Determine status identifier (case-insensitive). if ( strcasecmp( $status, "success" ) == 0 ) { $res->setStatus( IDEAL_TX_STATUS_SUCCESS ); } else if ( strcasecmp( $status, "Cancelled" ) == 0 ) { $res->setStatus( IDEAL_TX_STATUS_CANCELLED ); } else if ( strcasecmp( $status, "Expired" ) == 0 ) { $res->setStatus( IDEAL_TX_STATUS_EXPIRED ); } else if ( strcasecmp( $status, "Failure" ) == 0 ) { $res->setStatus( IDEAL_TX_STATUS_FAILURE ); } else if ( strcasecmp( $status, "Open" ) == 0 ) { $res->setStatus( IDEAL_TX_STATUS_OPEN ); } // The verification of the response starts here. // The message as per the reference guide instructions. $message = $creationTime . $res->getTransactionID() . $status . $res->getConsumerAccountNumber(); $message = $this->strip( $message ); // The signature value in the response contains the signed hash // (signed by the signing key on the server) $signature64 = $this->ParseFromXml( "signatureValue", $response ); // The signed hash is base64 encoded and inserted into the XML as such $sig = base64_decode( $signature64 ); // The fingerprint is used as the identifier of the public key certificate. // It is sent as part of the response XML. $fingerprint = $this->ParseFromXml( "fingerprint", $response ); // The merchant should have the public certificate stored locally. $certfile = $this->getCertificateFileName( $fingerprint ); if ( ! $certfile ) { return false; } // Verify the message signature $valid = $this->verifyMessage( $certfile, $message, $sig ); if ( ! $valid ) { return false; } if (!$res) { return $response; } return $res; }
{ static function throwException($code, $data = null) { $message = ErrorMessages::getMessage($code); $rcpCode = ErrorMessages::getRpcCode($code); $httpStatus = ErrorMessages::getHttpStatus($code); throw (new ApplicationException($message, $code))->setData($data)->setHttpStatus($httpStatus)->setRpcErrorCode($rcpCode); } } function doSomething() { RequestFailed::throwException(ErrorMessages::SESSION_ERROR_SESSION_NOT_VALID_CODE, ['this is the data', 'something' => 'else']); // UserError::invalidData(); } try { doSomething(); // throw new FrameworkException(JSONRPC_ERROR_METHOD_NOT_FOUND, JSONRPC_ERROR_METHOD_NOT_FOUND_CODE); // throw new RequestFailedException( ERROR_SESSION_NOT_VALID, ERROR_SESSION_NOT_VALID_CODE ); } catch (\Exception $exception) { print " catch : " . get_class($exception) . "\n"; $errorResponse = \ErrorResponse::fromException($exception); var_dump($errorResponse); print_r($errorResponse->getData()['trace']); return; print "Exception caught: \n"; print "\t" . get_class($exception) . "\n"; print "\t\t http Status : " . $exception->getHttpStatus() . "\n"; print "\t\t message : " . $exception->getMessage() . "\n"; print "\t\t error code : " . $exception->getCode() . "\n"; print "\t\t data : " . print_r($exception->getData(), true) . "\n"; }