diff --git a/src/Exception/VespaException.php b/src/Exception/VespaException.php index 31d1f45..5b1d75d 100644 --- a/src/Exception/VespaException.php +++ b/src/Exception/VespaException.php @@ -6,6 +6,8 @@ class VespaException extends \Exception { public function __construct($message, \Exception $exception = null) { - parent::__construct($message, 001, $exception); + $previous_message = $exception ? "\n{$exception->getMessage()}" : ""; + + parent::__construct("{$message}{$previous_message}", 001, $exception); } } diff --git a/src/Exception/VespaExecuteJobException.php b/src/Exception/VespaExecuteJobException.php index f93d8a8..3bdd857 100644 --- a/src/Exception/VespaExecuteJobException.php +++ b/src/Exception/VespaExecuteJobException.php @@ -9,10 +9,12 @@ class VespaExecuteJobException extends VespaException public function __construct(string $job_class, string $document_type, \Exception $exception = null, string $message = null) { + $previous_message = $exception ? "\n{$exception->getMessage()}" : ""; + if (!$message) { - parent::__construct("[{$document_type}] The job $job_class process failed", $exception); + parent::__construct("[{$document_type}] The job $job_class process failed.$previous_message", $exception); } else { - parent::__construct("[{$document_type}] $job_class - $message", $exception); + parent::__construct("[{$document_type}] $job_class - $message$previous_message", $exception); } $this->code = 600; diff --git a/src/Exception/VespaFailDeleteDocumentException.php b/src/Exception/VespaFailDeleteDocumentException.php index 484b728..01badf3 100644 --- a/src/Exception/VespaFailDeleteDocumentException.php +++ b/src/Exception/VespaFailDeleteDocumentException.php @@ -9,7 +9,9 @@ class VespaFailDeleteDocumentException extends VespaException public function __construct($definition, string $scheme, \Exception $exception = null) { - parent::__construct("[{$definition->getDocumentType()}]: An error occurred while deleting the document to the scheme : $scheme.", $exception); + $previous_message = $exception ? " {$exception->getMessage()}" : ""; + + parent::__construct("[{$definition->getDocumentType()}]: An error occurred while deleting the document to the scheme : $scheme.$previous_message", $exception); $this->code = 100; $this->definition = $definition; diff --git a/src/Exception/VespaFailGetDocumentException.php b/src/Exception/VespaFailGetDocumentException.php index f8b0eb1..3892643 100644 --- a/src/Exception/VespaFailGetDocumentException.php +++ b/src/Exception/VespaFailGetDocumentException.php @@ -11,7 +11,9 @@ class VespaFailGetDocumentException extends VespaException public function __construct(DocumentDefinition $definition, string $scheme, \Exception $exception) { - parent::__construct("[{$definition->getDocumentType()}]: An error occurred while getting the document to the scheme: $scheme", $exception); + $previous_message = $exception ? " {$exception->getMessage()}" : ""; + + parent::__construct("[{$definition->getDocumentType()}]: An error occurred while getting the document to the scheme: $scheme.$previous_message", $exception); $this->code = $exception->getCode(); $this->definition = $definition; diff --git a/src/Exception/VespaFailSearchException.php b/src/Exception/VespaFailSearchException.php index 17ffcdd..0938e1f 100644 --- a/src/Exception/VespaFailSearchException.php +++ b/src/Exception/VespaFailSearchException.php @@ -8,7 +8,9 @@ class VespaFailSearchException extends VespaException public function __construct(array $data, \Exception $exception = null) { - parent::__construct("An error occurred while performing the search on Vespa. Payload: " . json_encode($data), $exception); + $previous_message = $exception ? "\n{$exception->getMessage()}" : ""; + + parent::__construct("An error occurred while performing the search on Vespa. Payload: " . json_encode($data) . $previous_message, $exception); $this->code = 300; $this->payload = $data; diff --git a/src/Exception/VespaFailSendDocumentException.php b/src/Exception/VespaFailSendDocumentException.php index f2d2416..0b1a7bb 100644 --- a/src/Exception/VespaFailSendDocumentException.php +++ b/src/Exception/VespaFailSendDocumentException.php @@ -12,7 +12,9 @@ class VespaFailSendDocumentException extends VespaException public function __construct(DocumentDefinition $definition, AbstractDocument $document, \Exception $exception = null) { - parent::__construct("[{$definition->getDocumentType()}]: Document {$document->getVespaDocumentId()} was not indexed to Vespa.", $exception); + $previous_message = $exception ? " {$exception->getMessage()}" : ""; + + parent::__construct("[{$definition->getDocumentType()}]: Document {$document->getVespaDocumentId()} was not indexed to Vespa.{$previous_message}", $exception); $this->code = 400; $this->document = $document; diff --git a/src/Exception/VespaFailUpdateDocumentException.php b/src/Exception/VespaFailUpdateDocumentException.php index 9f17c21..39a714c 100644 --- a/src/Exception/VespaFailUpdateDocumentException.php +++ b/src/Exception/VespaFailUpdateDocumentException.php @@ -12,7 +12,9 @@ class VespaFailUpdateDocumentException extends VespaException public function __construct(DocumentDefinition $definition, AbstractDocument $document, \Exception $exception = null) { - parent::__construct("[{$definition->getDocumentType()}]: Document {$document->getVespaDocumentId()} was not updated to Vespa.", $exception); + $previous_message = $exception ? " {$exception->getMessage()}" : ""; + + parent::__construct("[{$definition->getDocumentType()}]: Document {$document->getVespaDocumentId()} was not updated to Vespa.$previous_message", $exception); $this->code = 500; $this->document = $document; diff --git a/src/Exception/VespaFeedException.php b/src/Exception/VespaFeedException.php index 02a2e53..14c95e2 100644 --- a/src/Exception/VespaFeedException.php +++ b/src/Exception/VespaFeedException.php @@ -8,10 +8,12 @@ class VespaFeedException extends VespaException public function __construct(string $model, \Exception $exception = null, string $message = null) { + $previous_message = $exception ? "\n{$exception->getMessage()}" : ""; + if (!$message) { - parent::__construct("[{$model}] Feed process failed", $exception); + parent::__construct("[{$model}] Feed process failed.$previous_message", $exception); } else { - parent::__construct("[{$model}] $message", $exception); + parent::__construct("[{$model}] $message$previous_message", $exception); } $this->code = 600; diff --git a/src/Exception/VespaInvalidHostException.php b/src/Exception/VespaInvalidHostException.php index e2c36f3..e77211c 100644 --- a/src/Exception/VespaInvalidHostException.php +++ b/src/Exception/VespaInvalidHostException.php @@ -6,7 +6,9 @@ class VespaInvalidHostException extends VespaException { public function __construct(\Exception $exception = null) { - parent::__construct("Invalid Vespa Host", $exception); + $previous_message = $exception ? " {$exception->getMessage()}" : ""; + + parent::__construct("Invalid Vespa Host.$previous_message", $exception); $this->code = 700; } diff --git a/src/Exception/VespaInvalidYQLQueryException.php b/src/Exception/VespaInvalidYQLQueryException.php index 6c8643f..4600186 100644 --- a/src/Exception/VespaInvalidYQLQueryException.php +++ b/src/Exception/VespaInvalidYQLQueryException.php @@ -6,10 +6,12 @@ class VespaInvalidYQLQueryException extends VespaException { public function __construct($message = null, \Exception $exception = null) { + $previous_message = $exception ? "\n{$exception->getMessage()}" : ""; + if ($message != null) { $message = " $message"; } - parent::__construct("Could not instantiate query from YQL.$message", $exception); + parent::__construct("Could not instantiate query from YQL.$message${previous_message}", $exception); $this->code = 800; }