| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- class StorageException extends Exception {
- public function __construct($message = null, $code = 0, Exception $previous = null) {
- if (is_array($message)) {
- if (count($message) > 0) {
- $dsErrors = array();
- foreach ($message as $vMsg) {
- $dsErrors[] = self::parseMessage($vMsg);
- }
- $message = implode("\n", $dsErrors);
- } else {
- $message = 'XXX' . json_encode($message);// DBG
- }
- } else {
- $message = self::parseMessage($message);
- }
- return parent::__construct($message, $code, $previous);
- }
- public static function parseMessage($message) {
- $parsedMsg = $message;
- // UPDATE `P5-MSG:Route_FixZasobPath:ERROR: Loop detected in path` SET x=1;
- //echo "\nMSG: ({$message})\n";
- //echo "\nMSG substr(0, 7): (" . substr($message, 0, 7) . ") substr(-15): (" . substr($message, -15) . ")\n";
- if ("Table '" == substr($message, 0, 7) && "' doesn't exist" == substr($message, -15)) {
- // #1146 - Table '{DATABASE_NAME}.P5-MSG:{CLASS_NAME}:WARNING: Update all paths' doesn't exist
- // #1146 - Table '{DATABASE_NAME}.P5-MSG:{CLASS_NAME}:ERROR: Loop detected ID=P_ID' doesn't exist
- // #1146 - Table '{DATABASE_NAME}.P5-MSG:{CLASS_NAME}:ERROR: Parent item not exists' doesn't exist
- // #1146 - Table '{DATABASE_NAME}.P5-MSG:{CLASS_NAME}:ERROR: Loop detected in path' doesn't exist
- $clsName = null;
- $tmpMsg = $message;
- $tmpMsg = substr($tmpMsg, 7);
- $tmpMsg = substr($tmpMsg, 0, -15);
- if (false !== ($pos = strpos($tmpMsg, '.P5-MSG:'))) {
- $tmpMsg = substr($tmpMsg, $pos + 8);
- //echo "DBG has P5-MSG({$tmpMsg})\n";
- }
- if (false !== ($pos = strpos($tmpMsg, ':'))) {
- $clsName = substr($tmpMsg, 0, $pos);
- $tmpMsg = substr($tmpMsg, $pos + 1);
- //echo "DBG has class({$clsName}) msg({$tmpMsg})\n";
- }
- if ($clsName) {
- if (Lib::tryLoadClass($clsName)) {
- $obj = new $clsName();
- $methodName = 'parseMessageFromStorage';
- if (method_exists($obj, $methodName)) {
- $parsedMsg = $obj->{$methodName}($tmpMsg);
- }
- }
- }
- }
- return $parsedMsg;
- }
- }
|