Skip to content

Commit 27f15b0

Browse files
committed
Rename and introduce sta exception.
1 parent 3ec9c5d commit 27f15b0

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

src/Commands/Backup/CreateCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Pantheon\Terminus\Commands\WorkflowProcessingTrait;
66
use Pantheon\Terminus\Models\Backup;
7+
use Pantheon\Terminus\Exceptions\TerminusStaSiteException;
78

89
/**
910
* Class CreateCommand.
@@ -43,7 +44,13 @@ public function create($site_env, $options = ['element' => 'all', 'keep-for' =>
4344
? $options['keep-for']
4445
: Backup::DEFAULT_TTL;
4546
$options['element'] = isset($options['element']) ? $this->getElement($options['element']) : null;
46-
$this->processWorkflow($env->getBackups()->create($options));
47+
try {
48+
$this->processWorkflow($env->getBackups()->create($options));
49+
} catch (TerminusStaSiteException $e) {
50+
$this->log()->notice("This command is not supported for this site.");
51+
$this->log()->debug($e->getMessage());
52+
return;
53+
}
4754
$this->log()->notice(
4855
'Created a backup of the {env} environment.',
4956
['env' => $env->getName()]

src/Commands/Branch/ListCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Pantheon\Terminus\Commands\StructuredListTrait;
88
use Pantheon\Terminus\Site\SiteAwareInterface;
99
use Pantheon\Terminus\Site\SiteAwareTrait;
10-
use Pantheon\Terminus\Exceptions\TerminusIcrSiteException;
10+
use Pantheon\Terminus\Exceptions\TerminusEvcsSiteException;
1111

1212
/**
1313
* Class ListCommand
@@ -42,8 +42,8 @@ public function listBranches($site_id)
4242
{
4343
try {
4444
return $this->getRowsOfFields($this->getSiteById($site_id)->getBranches());
45-
} catch (TerminusIcrSiteException $e) {
46-
$this->log()->notice("This is an ICR site, branches are managed in the external VCS.");
45+
} catch (TerminusEvcsSiteException $e) {
46+
$this->log()->notice("This command is not supported for sites using version control systems external to Pantheon.");
4747
$this->log()->debug($e->getMessage());
4848
return;
4949
}

src/Commands/Connection/SetCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Pantheon\Terminus\Site\SiteAwareInterface;
88
use Pantheon\Terminus\Site\SiteAwareTrait;
99
use Pantheon\Terminus\Exceptions\TerminusException;
10-
use Pantheon\Terminus\Exceptions\TerminusIcrSiteException;
10+
use Pantheon\Terminus\Exceptions\TerminusEvcsSiteException;
1111

1212
/**
1313
* Class SetCommand.
@@ -66,9 +66,9 @@ public function connectionSet($site_env, $mode)
6666
try {
6767
$mode = strtolower($mode ?? '');
6868
$workflow = $env->changeConnectionMode($mode);
69-
} catch (TerminusIcrSiteException $e) {
69+
} catch (TerminusEvcsSiteException $e) {
7070
$this->log()->debug($e->getMessage());
71-
$this->log()->notice("This is an ICR site, connection mode switching is not currently supported.");
71+
$this->log()->notice("This command is not supported for sites using version control systems external to Pantheon.");
7272
return;
7373
} catch (TerminusException $e) {
7474
$message = $e->getMessage();

src/Exceptions/TerminusIcrSiteException.php renamed to src/Exceptions/TerminusEvcsSiteException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Pantheon\Terminus\Exceptions;
44

55
/**
6-
* Class TerminusIcrSiteException
6+
* Class TerminusEvcsSiteException
77
* @package Pantheon\Terminus\Exceptions
88
*/
9-
class TerminusIcrSiteException extends TerminusException
9+
class TerminusEvcsSiteException extends TerminusException
1010
{
1111
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Pantheon\Terminus\Exceptions;
4+
5+
/**
6+
* Class TerminusStaSiteException
7+
* @package Pantheon\Terminus\Exceptions
8+
*/
9+
class TerminusStaSiteException extends TerminusEvcsSiteException
10+
{
11+
}

src/Request/Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use League\Container\ContainerAwareTrait;
1616
use Pantheon\Terminus\Config\ConfigAwareTrait;
1717
use Pantheon\Terminus\Exceptions\TerminusException;
18-
use Pantheon\Terminus\Exceptions\TerminusIcrSiteException;
18+
use Pantheon\Terminus\Exceptions\TerminusEvcsSiteException;
1919
use Pantheon\Terminus\Helpers\LocalMachineHelper;
2020
use Pantheon\Terminus\Helpers\Utility\TraceId;
2121
use Pantheon\Terminus\Session\SessionAwareInterface;
@@ -442,9 +442,9 @@ public function request($path, array $options = []): RequestOperationResult
442442
}
443443
}
444444

445-
if ($response->getStatusCode() == 409 && $body == "icr_site") {
446-
// This request is expected to fail for an ICR site, throw exception that will be catched down the road.
447-
throw new TerminusIcrSiteException("This is an ICR site.");
445+
if ($response->getStatusCode() == 409 && $body == "evcs_site") {
446+
// This request is expected to fail for an eVCS site, throw exception that will be catched down the road.
447+
throw new TerminusEvcsSiteException("This is a site with an external version control system so this is not supported.");
448448
}
449449

450450
return new RequestOperationResult([

0 commit comments

Comments
 (0)