Skip to content

Commit 0f50989

Browse files
committed
MAGETWO-67722: Add ability to inject exception code in LocalizedException #9363
- Expanded initial implementation
1 parent d902e08 commit 0f50989

File tree

11 files changed

+28
-19
lines changed

11 files changed

+28
-19
lines changed

app/code/Magento/Paypal/Model/Api/ProcessableException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ProcessableException extends LocalizedException
4040
*/
4141
public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0)
4242
{
43-
parent::__construct($phrase, $cause);
43+
parent::__construct($phrase, $cause, $code);
4444
$this->code = $code;
4545
}
4646

app/code/Magento/Search/Model/Synonym/MergeConflictException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ class MergeConflictException extends LocalizedException
2828
* @param array $conflictingSynonyms
2929
* @param Phrase|null $phrase
3030
* @param \Exception|null $cause
31+
* @param int $code
3132
*/
32-
public function __construct(array $conflictingSynonyms, Phrase $phrase = null, \Exception $cause = null)
33+
public function __construct(array $conflictingSynonyms, Phrase $phrase = null, \Exception $cause = null, $code = 0)
3334
{
34-
parent::__construct($phrase, $cause);
35+
parent::__construct($phrase, $cause, $code);
3536
$this->conflictingSynonyms = $conflictingSynonyms;
3637
}
3738

app/code/Magento/Store/Model/StoreIsInactiveException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ class StoreIsInactiveException extends LocalizedException
1616
/**
1717
* @param \Magento\Framework\Phrase $phrase
1818
* @param \Exception $cause
19+
* @param int $code
1920
*/
20-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
21+
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
2122
{
2223
if ($phrase === null) {
2324
$phrase = new Phrase('Store is inactive');
2425
}
25-
parent::__construct($phrase, $cause);
26+
parent::__construct($phrase, $cause, $code);
2627
}
2728
}

lib/internal/Magento/Framework/Exception/AbstractAggregateException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ abstract class AbstractAggregateException extends LocalizedException
3939
*
4040
* @param \Magento\Framework\Phrase $phrase
4141
* @param \Exception $cause
42+
* @param int $code
4243
*/
43-
public function __construct(Phrase $phrase, \Exception $cause = null)
44+
public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0)
4445
{
4546
$this->originalPhrase = $phrase;
46-
parent::__construct($phrase, $cause);
47+
parent::__construct($phrase, $cause, $code);
4748
}
4849

4950
/**

lib/internal/Magento/Framework/Exception/AlreadyExistsException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ class AlreadyExistsException extends LocalizedException
1515
/**
1616
* @param Phrase $phrase
1717
* @param \Exception $cause
18+
* @param int $code
1819
*/
19-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
20+
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
2021
{
2122
if ($phrase === null) {
2223
$phrase = new Phrase('Unique constraint violation found');
2324
}
24-
parent::__construct($phrase, $cause);
25+
parent::__construct($phrase, $cause, $code);
2526
}
2627
}

lib/internal/Magento/Framework/Exception/InputException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ class InputException extends AbstractAggregateException
4949
*
5050
* @param \Magento\Framework\Phrase $phrase
5151
* @param \Exception $cause
52+
* @param int $code
5253
*/
53-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
54+
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
5455
{
5556
if ($phrase === null) {
5657
$phrase = new Phrase('One or more input exceptions have occurred.');
5758
}
58-
parent::__construct($phrase, $cause);
59+
parent::__construct($phrase, $cause, $code);
5960
}
6061

6162
/**

lib/internal/Magento/Framework/Exception/NoSuchEntityException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ class NoSuchEntityException extends LocalizedException
2727
/**
2828
* @param \Magento\Framework\Phrase $phrase
2929
* @param \Exception $cause
30+
* @param int $code
3031
*/
31-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
32+
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
3233
{
3334
if ($phrase === null) {
3435
$phrase = new Phrase('No such entity.');
3536
}
36-
parent::__construct($phrase, $cause);
37+
parent::__construct($phrase, $cause, $code);
3738
}
3839

3940
/**

lib/internal/Magento/Framework/Exception/SerializationException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ class SerializationException extends LocalizedException
2727
/**
2828
* @param \Magento\Framework\Phrase $phrase
2929
* @param \Exception $cause
30+
* @param int $code
3031
*/
31-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
32+
public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
3233
{
3334
if ($phrase === null) {
3435
$phrase = new Phrase('One or more input exceptions have occurred.');
3536
}
36-
parent::__construct($phrase, $cause);
37+
parent::__construct($phrase, $cause, $code);
3738
}
3839
}

lib/internal/Magento/Framework/Exception/TemporaryState/CouldNotSaveException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CouldNotSaveException extends LocalizedCouldNotSaveException implements Te
2525
*/
2626
public function __construct(Phrase $phrase, \Exception $previous = null, $code = 0)
2727
{
28-
parent::__construct($phrase, $previous);
28+
parent::__construct($phrase, $previous, $code);
2929
$this->code = $code;
3030
}
3131
}

lib/internal/Magento/Framework/Validator/Exception.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class Exception extends InputException
3030
* @param \Magento\Framework\Phrase $phrase
3131
* @param \Exception $cause
3232
* @param array $messages Validation error messages
33+
* @param int $code
3334
*/
3435
public function __construct(
3536
Phrase $phrase = null,
3637
\Exception $cause = null,
37-
array $messages = []
38+
array $messages = [],
39+
$code = 0
3840
) {
3941
if (!empty($messages)) {
4042
$message = '';
@@ -49,7 +51,7 @@ public function __construct(
4951
}
5052
$phrase = new Phrase($message);
5153
}
52-
parent::__construct($phrase, $cause);
54+
parent::__construct($phrase, $cause, $code);
5355
}
5456

5557
/**

lib/internal/Magento/Framework/Webapi/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function __construct(
105105
if ($httpCode < 400 || $httpCode > 599) {
106106
throw new \InvalidArgumentException(sprintf('The specified HTTP code "%d" is invalid.', $httpCode));
107107
}
108-
parent::__construct($phrase);
108+
parent::__construct($phrase, null, $code);
109109
$this->code = $code;
110110
$this->_httpCode = $httpCode;
111111
$this->_details = $details;

0 commit comments

Comments
 (0)