a50d36e7b4
- correction de bug
99 lines
4.4 KiB
PHP
99 lines
4.4 KiB
PHP
<?php
|
||
Class SOAPCatchError
|
||
{
|
||
private $MessageUtilisateur;
|
||
|
||
private $tabType = array('CommonPlatform', 'Provider');
|
||
|
||
private $CommonPlatform = array(
|
||
'1000' => array('Functional'=> 'Authentication failed <details>'),
|
||
'1001' => array('Functional'=> 'Invalid Provider supplied <ProviderId>.'),
|
||
'1002' => array('Functional'=> 'Impersonation detected. <ConsumerId> tries to impersonate <AnotherPartner>.'),
|
||
'1005' => array('Functional'=> 'Failed to validate message. Reason <details>.'),
|
||
'1010' => array('Functional'=> 'Invalid Provider/Country combination.'),
|
||
'1015' => array('Functional'=> 'Provider <ProviderId> cannot be used in combination with other providers.'),
|
||
'1020' => array('Functional'=> 'Invalid Consumer supplied <ConsumerId>'),
|
||
'3100' => array('Functional'=> 'Unable to lookup order. No InternalOrderId supplied.'),
|
||
'3101' => array('Functional'=> 'Unable to lookup order. Invalid InternalOrderId <InternalOrderId> supplied.'),
|
||
'3110' => array('Functional'=> 'Your query returns more than <x> records. Please specify your query.'),
|
||
'4000' => array('Functional'=> 'Invalid ProviderOrderId <ProviderOrderId>.'),
|
||
'4001' => array('Functional'=> 'Duplicate ProviderEventId <ProviderEventId>.'),
|
||
'4002' => array('Functional'=> 'Invalid NumberOfEvents <NumberOfEvents>.'),
|
||
'6000' => array('Functional'=> 'Error connecting to search component.'),
|
||
'6099' => array('Functional'=> 'Unexpected exception.'),
|
||
'7000' => array('Functional'=> 'Could not connect to <ProviderId>'),
|
||
'7099' => array('Functional'=> 'Unexpected exception.'),
|
||
'8000' => array('Functional'=> 'Problem connecting to database.'),
|
||
'8010' => array('Functional'=> 'Configuration exception <details>.'),
|
||
'8090' => array('Functional'=> 'Internal exception during search <details>.'),
|
||
'8099' => array('Functional'=> 'Unexpected exception <details>.')
|
||
);
|
||
|
||
private $Provider = array(
|
||
'1003' => array('Functional'=> 'Authorization failed.'),
|
||
'3000' => array('Functional'=> 'Invalid CompanyId <CompanyId>'),
|
||
'3001' => array('Functional'=> 'Invalid Version <version> requested.'),
|
||
'3002' => array('Functional'=> 'Invalid LanguageCode <languageCode> requested.'),
|
||
'3003' => array('Functional'=> 'Invalid DataSetType <dataSetType> requested.'),
|
||
'3004' => array('Functional'=> 'Invalid ServiceLevel <serviceLevel> requested.'),
|
||
'3005' => array('Functional'=> 'Invalid CategoryName <categoryName> requested'),
|
||
'3006' => array('Functional'=> 'Invalid EventType <eventType> requested.'),
|
||
'3007' => array('Functional'=> 'Invalid Date format.'),
|
||
'3020' => array('Functional'=> 'Invalid OrderId <OrderId>.'),
|
||
'3021' => array('Functional'=> 'Invalid OrderId / Consumer combination.'),
|
||
'3022' => array('Functional'=> 'Invalid OrderType.'),
|
||
'3023' => array('Functional'=> 'Can’t retrieve dataset. Invalid Order Status <OrderStatus>.'),
|
||
'5xxx' => array('Functional'=> 'Provider specific functional errorCodes.'),
|
||
'9xxx' => array('Functional'=> 'Provider specific technical errorCodes.')
|
||
);
|
||
|
||
function __construct() {
|
||
}
|
||
|
||
private function selectErreurInTab($SoapObj) {
|
||
foreach ($this->tabType as $champ)
|
||
{
|
||
foreach($this->$champ as $chmp => $valeur) {
|
||
if ($chmp == $SoapObj->ErrorCode)
|
||
$this->MessageUtilisateur = date('d/m/Y à h:i:s').' ['.$chmp.'] '.$valeur['Functional']."\r\n";
|
||
}
|
||
}
|
||
return (date('dmY-h:i:s').' ['.$SoapObj->ErrorCode.'] '.$SoapObj->ErrorMessage."\r\n");
|
||
}
|
||
|
||
public function _printInLogs($SoapObj) {
|
||
if (isset($SoapObj)) {
|
||
if (($erreur = self::selectErreurInTab($SoapObj->TechnicalException)))
|
||
{
|
||
if (file_put_contents(_LOGS_PROVIDER_.'/logs.txt', $content.$erreur, FILE_APPEND))
|
||
{
|
||
self::sendMailError($erreur);
|
||
if(empty($this->MessageUtilisateur))
|
||
$this->MessageUtilisateur = $erreur;
|
||
return(EXIT_FAILURE);
|
||
}
|
||
}
|
||
}
|
||
return (EXIT_SUCCESS);
|
||
}
|
||
|
||
public function sendMailError($erreur) {
|
||
$headers ='From: '.EMAIL_SUPPORTDEV."\n";
|
||
$headers .='Reply-To:'.EMAIL_SUPPORTDEV."\n";
|
||
$headers .='Content-Type: text/plain; charset="UTF-8"'."\n";
|
||
$headers .='Content-Transfer-Encoding: 8bit';
|
||
|
||
$subject = '[Erreur SOAP Giant] ';
|
||
|
||
$content = 'Le '.date('d-m-Y').' Giant a retourné une erreur SOAP à '.date ('h:i:s')."\n";
|
||
$content .= 'Erreur : '.$erreur;
|
||
|
||
mail(EMAIL_SUPPORTDEV, $subject, $content, $headers);
|
||
}
|
||
|
||
public function _getMessage(){
|
||
return ($this->MessageUtilisateur);
|
||
}
|
||
|
||
}
|
||
?>
|