|
15 | 15 | use League\Container\ContainerAwareTrait; |
16 | 16 | use Pantheon\Terminus\Config\ConfigAwareTrait; |
17 | 17 | use Pantheon\Terminus\Exceptions\TerminusException; |
18 | | -use Pantheon\Terminus\Exceptions\TerminusEvcsSiteException; |
| 18 | +use Pantheon\Terminus\Exceptions\TerminusUnsupportedSiteException; |
19 | 19 | use Pantheon\Terminus\Helpers\LocalMachineHelper; |
20 | 20 | use Pantheon\Terminus\Helpers\Utility\TraceId; |
21 | 21 | use Pantheon\Terminus\Session\SessionAwareInterface; |
@@ -74,14 +74,7 @@ class Request implements |
74 | 74 | 'CI', |
75 | 75 | ]; |
76 | 76 |
|
77 | | - public const EVCS_SITE_RESPONSE = 'evcs_site'; |
78 | | - |
79 | | - public const EVCS_SITE_EXCEPTION_MESSAGE = |
80 | | - 'This is a site with an external version control system so this is not supported.'; |
81 | | - |
82 | | - public const STA_SITE_RESPONSE = 'sta_site'; |
83 | | - |
84 | | - public const STA_SITE_EXCEPTION_MESSAGE = 'This is not supported for this site.'; |
| 77 | + public const UNSUPPORTED_SITE_EXCEPTION_MESSAGE = 'This is not supported for this site.'; |
85 | 78 |
|
86 | 79 | protected ClientInterface $client; |
87 | 80 |
|
@@ -451,14 +444,16 @@ public function request($path, array $options = []): RequestOperationResult |
451 | 444 | } |
452 | 445 | } |
453 | 446 |
|
454 | | - if ($response->getStatusCode() == 409 && $body == self::EVCS_SITE_RESPONSE) { |
455 | | - // This request is expected to fail for an eVCS site, throw exception. |
456 | | - throw new TerminusEvcsSiteException(self::EVCS_SITE_EXCEPTION_MESSAGE); |
457 | | - } |
458 | | - |
459 | | - if ($response->getStatusCode() == 409 && $body == self::STA_SITE_RESPONSE) { |
460 | | - // This request is expected to fail for an STA site, throw exception. |
461 | | - throw new TerminusEvcsSiteException(self::STA_SITE_EXCEPTION_MESSAGE); |
| 447 | + if ($response->getStatusCode() == 409) { |
| 448 | + if (!empty($decoded_body) && !empty($decoded_body->message)) { |
| 449 | + // This request is expected to fail for an unsupported site, throw exception. |
| 450 | + throw new TerminusUnsupportedSiteException($decoded_body->message); |
| 451 | + } elseif (!empty($decoded_body) && !empty($decoded_body->reason)) { |
| 452 | + // This request is expected to fail, use generic reson. |
| 453 | + throw new TerminusUnsupportedSiteException( |
| 454 | + self::UNSUPPORTED_SITE_EXCEPTION_MESSAGE |
| 455 | + ); |
| 456 | + } |
462 | 457 | } |
463 | 458 |
|
464 | 459 | return new RequestOperationResult([ |
|
0 commit comments