/**
  * @param \SoapFault $fault
  *
  * @return WebserviceException
  * @throws ServerException
  */
 public function convertToException($fault)
 {
     $errorClassName = isset($fault->{'detail'}->{'errorcode'}) ? $fault->{'detail'}->{'errorcode'} : 'Server';
     $errorClassFQ = 'WebservicesNl\\Common\\Exception\\' . str_replace('.', '\\', $errorClassName) . 'Exception';
     // should we throw an error about throwing an error? or just create a default error?
     if (!class_exists($errorClassFQ)) {
         throw new ServerException("Could not convert errorCode: '{$errorClassName}'");
     }
     /** @var WebserviceException $exception */
     return new $errorClassFQ($fault->getMessage(), $fault->getCode());
 }
 public function testFormatSoapFaultException()
 {
     if (!class_exists('SoapFault')) {
         $this->markTestSkipped('Requires the soap extension');
     }
     $formatter = new NormalizerFormatter('Y-m-d');
     $e = new \SoapFault('foo', 'bar', 'hello', 'world');
     $formatted = $formatter->format(array('exception' => $e));
     unset($formatted['exception']['trace']);
     $this->assertEquals(array('exception' => array('class' => 'SoapFault', 'message' => 'bar', 'code' => 0, 'file' => $e->getFile() . ':' . $e->getLine(), 'faultcode' => 'foo', 'faultactor' => 'hello', 'detail' => 'world')), $formatted);
 }
 /**
  * Generate a server fault
  *
  * Note that the arguments are the reverse of those used by SoapFault.
  *
  * Moodle note: the difference with the Zend server is that we throw a SoapFault exception
  * with the debuginfo integrated in the exception message when DEBUG >= NORMAL
  *
  * If an exception is passed as the first argument, its message and code
  * will be used to create the fault object if it has been registered via
  * {@Link registerFaultException()}.
  *
  * @link   http://www.w3.org/TR/soap12-part1/#faultcodes
  * @param  string|Exception $fault
  * @param  string $code SOAP Fault Codes
  * @return SoapFault
  */
 public function fault($fault = null, $code = "Receiver")
 {
     //intercept any exceptions with debug info and transform it in Moodle exception
     if ($fault instanceof Exception) {
         //add the debuginfo to the exception message if debuginfo must be returned
         if (debugging() and isset($fault->debuginfo)) {
             $fault = new SoapFault('Receiver', $fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo);
         }
     }
     return parent::fault($fault, $code);
 }
 /**
  * Create a new SoapException.
  */
 public function __construct(\SoapFault $fault, \SoapClient $client)
 {
     $message = $fault->getMessage();
     $code = $fault->getCode();
     if ($message === "UPnPError") {
         $code = $fault->detail->UPnPError->errorCode;
         $message .= ": {$code}";
     }
     parent::__construct($message, $code);
     $this->client = $client;
 }
 /**
  * {@inheritdoc}
  */
 public function handle(\SoapFault $e)
 {
     $message = trim($e->getMessage());
     foreach ($this->classes as $class) {
         $results = array();
         if (preg_match('`' . str_replace('%s', '(.*?)', $class::MESSAGE) . '`is', $message, $results)) {
             $rc = new \ReflectionClass($class);
             unset($results[0]);
             throw $rc->newInstanceArgs($results);
         }
     }
     throw new ClientException($message, $e->getCode(), $e);
 }
 /**
  * @param \SoapFault $fault
  * @return SoapFaultException|null
  */
 public static function forSoapFault(\SoapFault $fault)
 {
     if (!preg_match('/(?:ICE|ERR)_(?P<code>[0-9]+):\\s(?P<message>.*)/', $fault->getMessage(), $matches)) {
         return new self($fault->getMessage(), -1, $fault);
     }
     $code = intval($matches['code']);
     $message = $matches['message'];
     // If the code indicates a 404 (not found) then return null
     if (in_array($code, [6, 9], true)) {
         return null;
     }
     return new self($message, $code, $fault);
 }
Exemple #7
0
 /**
  * Creates a new ApiException (or an extending exception) based on the
  * error code given by the soap fault.
  *
  * The exact exception type can be found out from ApiException::$exceptions.
  * ApiException is thrown, if the message code is not found or a specific
  * exception type is not defined.
  *
  * @param SoapFault $e
  *
  * @return ApiException
  */
 public static function createFromSoapFault(\SoapFault $e)
 {
     $code = (int) $e->getMessage();
     $message = 'Request failed';
     if (isset(self::$messages[$code])) {
         $message = self::$messages[$code];
         $class = isset(self::$exceptions[$code]) ? self::$exceptions[$code] : null;
         if ($class) {
             $class = 'KG\\DigigDoc\\Exception\\' . $class;
             return new $class($message, $code, $e);
         }
     }
     return new static($message, $code, $e);
 }
 public static function soapFault(\SoapFault $e)
 {
     $code = $e->getMessage();
     // fix undefined index error in HHVM
     if (!in_array($code, array_keys(static::$errorCodeMap))) {
         $xml = $e->getMessage();
         $faultString = '<faultstring xml:lang="en">';
         $code = substr($xml, strpos($xml, $faultString) + strlen($faultString), 3);
     }
     $message = static::$errorCodeMap[$code];
     if (isset($e->detail) && isset($e->detail->message)) {
         $message .= ' ' . $e->detail->message;
     }
     return new static($message, (int) $code, $e);
 }
 /**
  * @return InkRouter_Exceptions_Exception
  */
 public function getException()
 {
     if (!isset($this->exception)) {
         if (isset($this->fault->detail)) {
             $classVars = get_object_vars($this->fault->detail);
             $classProps = array_keys($classVars);
             switch ($classProps[0]) {
                 case self::AUTHENTICATION_EXCEPTION:
                     $this->exception = new InkRouter_Exceptions_AuthenticationException($this->fault->getMessage());
                     break;
                 case self::PROCESSING_EXCEPTION:
                     $this->exception = new InkRouter_Exceptions_ProcessingException($this->fault->getMessage());
                     break;
                 case self::REJECTION_EXCEPTION:
                     $this->exception = new InkRouter_Exceptions_RejectionException($this->fault->getMessage());
                     break;
                 default:
                     $this->exception = new InkRouter_Exceptions_InkRouterNotAvailableException($this->fault->getMessage());
                     break;
             }
         } else {
             $this->exception = new InkRouter_Exceptions_InkRouterNotAvailableException($this->fault->getMessage());
         }
     }
     return $this->exception;
 }
 public function __construct($error_no, $function_name)
 {
     global $CbgrnAPIErrorMessage;
     $locale = CBGRNAPI_ERROR_LANG;
     switch ($locale) {
         case "jp":
             $locale = "en";
             break;
         default:
             $locale = "en";
     }
     $error_no = sprintf("%03d", $error_no);
     $err_code = "CbgrnAPI" . $error_no;
     $err_msg = $function_name . " : " . $CbgrnAPIErrorMessage[$locale][$error_no];
     parent::__construct($err_code, $err_msg);
 }
 /**
  * Verify that SOAP fault contains necessary information.
  *
  * @param \SoapFault $soapFault
  * @param string $expectedMessage
  * @param string $expectedFaultCode
  * @param array $expectedErrorParams
  * @param array $expectedWrappedErrors
  * @param string $traceString
  */
 protected function checkSoapFault($soapFault, $expectedMessage, $expectedFaultCode, $expectedErrorParams = [], $expectedWrappedErrors = [], $traceString = null)
 {
     $this->assertContains($expectedMessage, $soapFault->getMessage(), "Fault message is invalid.");
     $errorDetailsNode = 'GenericFault';
     $errorDetails = isset($soapFault->detail->{$errorDetailsNode}) ? $soapFault->detail->{$errorDetailsNode} : null;
     if (!empty($expectedErrorParams) || !empty($expectedWrappedErrors)) {
         /** Check SOAP fault details */
         $this->assertNotNull($errorDetails, "Details must be present.");
         $this->_checkFaultParams($expectedErrorParams, $errorDetails);
         $this->_checkWrappedErrors($expectedWrappedErrors, $errorDetails);
     }
     if ($traceString) {
         /** Check error trace */
         $traceNode = Fault::NODE_DETAIL_TRACE;
         $mode = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->getMode();
         if ($mode == \Magento\Framework\App\State::MODE_DEVELOPER) {
             /** Developer mode changes tested behavior and it cannot properly be tested for now */
             $this->assertContains($traceString, $errorDetails->{$traceNode}, 'Trace Information is incorrect.');
         } else {
             $this->assertNull($errorDetails, "Details are not expected.");
         }
     }
     /** Check SOAP fault code */
     $this->assertNotNull($soapFault->faultcode, "Fault code must not be empty.");
     $this->assertEquals($expectedFaultCode, $soapFault->faultcode, "Fault code is invalid.");
 }
Exemple #12
0
 /**
  * Raise a soft error event which
  * will save errorto database.
  *
  * @param string $companySymbol
  * @param \Exception|\SoapFault $exception
  * @param $message
  */
 protected function raiseEvent($companySymbol, $exception, $message)
 {
     event(new SoftSoapErrorRaised($companySymbol, $exception->getCode(), $message, $exception->getTraceAsString()));
 }
Exemple #13
0
 public function __construct($code, $message = "")
 {
     parent::__construct("" . $code, $this->errors[$code] . $message);
 }
Exemple #14
0
 /**
  * Check SOAP login failure is an access denied
  * @param SoapFault $e A SoapFault Exception.
  * @return void
  */
 private function assertIsLoginFailure(SoapFault $e)
 {
     $this->assertRegexp('/Access denied/i', $e->getMessage());
 }
 public function __construct($faultstring, $faultactor = null, $detail = null, $faultname = null, $headerfault = null)
 {
     parent::__construct('Sender', $faultstring, $faultactor, $detail, $faultname, $headerfault);
 }
 /**
  * @param \SoapFault $e
  * @return ServiceException
  */
 protected function soapError(\SoapFault $e)
 {
     $this->log(Logger::ERR, 'SoapFault: ' . $e->getMessage());
     return ServiceException::soapFault($e);
 }
Exemple #17
0
 private function createException(\SoapFault $e)
 {
     return new IOException($e->getMessage(), $e->getCode(), $e);
 }
Exemple #18
0
 function __construct()
 {
     parent::__construct("MyFault", "My fault string");
 }
Exemple #19
0
 /**
  * @param AbstractModel|AbstractModel[]|\SoapFault $result
  * @throws InvalidArgument
  * @return $this;
  */
 public function setResult($result)
 {
     if ($result instanceof \SoapFault) {
         $this->setIsSoapFault(true);
         $this->setErrorCode($result->getCode());
         $this->setErrorMsg(SoapClientFactory::convertEncoding($result->getMessage()));
         $this->result = null;
         $this->setSoapFault($result);
     } else {
         $piece = $result;
         if (is_array($result)) {
             if (count($result)) {
                 $piece = reset($result);
             } else {
                 $piece = null;
             }
         }
         if ($piece !== null && !$piece instanceof AbstractModel && !$piece instanceof \SoapFault) {
             throw new InvalidArgument('O resultado deve ser uma instância de PhpSigep\\Model\\AbstractModel ou um ' . 'array de PhpSigep\\Model\\AbstractModel ou uma instância de \\SoapFault.');
         }
         $this->result = $result;
     }
     return $this;
 }
Exemple #20
0
 public function __construct($order)
 {
     parent::__construct('test', '1|Some error occurred.', null);
 }
Exemple #21
0
 /**
  * create and throw SSRSReportException from SoapFault object
  * @param SoapFault $soapFault
  */
 protected function ThrowReportException($soapFault)
 {
     if (isset($soapFault->detail) && is_object($soapFault->detail)) {
         throw new SSRSReportException($soapFault->detail->ErrorCode, $soapFault->detail->Message, $soapFault);
     } else {
         if (is_string($soapFault->detail) && !empty($soapFault->detail)) {
             throw new SSRSReportException('', $soapFault->detail, $soapFault);
         } else {
             $lines = explode("\n", $soapFault->getMessage());
             throw new SSRSReportException('', $lines[0], $soapFault);
         }
     }
 }
Exemple #22
0
 protected function catchSoapError(\SoapFault $e)
 {
     $code = $e->getMessage();
     throw new ServiceException($this->errorCodeMap[$code], $code);
 }
 /**
  * @param FaultCodeType $code
  * @param string $message
  */
 public function __construct($code, $message)
 {
     parent::__construct($code, $message);
 }
Exemple #24
0
 private function resolveMessage(\SoapFault $f)
 {
     $message = $f->getMessage();
     return $message == 'looks like we got no XML document' ? 'Query returned empty data set' : $message;
 }