Skip to content

Commit

Permalink
Fix exceptions not breaking execution of test
Browse files Browse the repository at this point in the history
  • Loading branch information
tr33m4n committed Feb 9, 2020
1 parent 113346a commit 445b890
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/Codeception/Module/Percy.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
class Percy extends Module
{
/**
* Module namespace, for use with exceptions
*/
const MODULE_NAMESPACE = 'Percy';

/**
* @var array
*/
Expand Down Expand Up @@ -62,6 +67,7 @@ public function _initialize()
$this->percyAgentJs = Client::fromUrl($this->buildUrl($this->_getConfig('agentJsPath')))->get();
} catch (Exception $exception) {
throw new SetupException(
self::MODULE_NAMESPACE,
sprintf(
'Cannot contact the Percy agent endpoint. Has Codeception been launched with `npx percy exec`? %s',
$exception->getMessage()
Expand Down Expand Up @@ -139,6 +145,7 @@ private function getSnapshotConfig() : array
}

throw new ConfigException(
self::MODULE_NAMESPACE,
sprintf('The following key is not allowed to be set through config: %s', $blacklistKey)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Percy/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Codeception\Module\Percy\Exception;

use Exception;
use Codeception\Exception\ModuleException;

/**
* Class ClientException
*
* @package Codeception\Module\Percy\Exception
*/
final class ClientException extends Exception
final class ClientException extends ModuleException
{
//
}
4 changes: 2 additions & 2 deletions src/Codeception/Module/Percy/Exception/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Codeception\Module\Percy\Exception;

use Exception;
use Codeception\Exception\ModuleException;

/**
* Class ConfigException
*
* @package Codeception\Module\Percy\Exception
*/
final class ConfigException extends Exception
final class ConfigException extends ModuleException
{
//
}
4 changes: 2 additions & 2 deletions src/Codeception/Module/Percy/Exception/SetupException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Codeception\Module\Percy\Exception;

use Exception;
use Codeception\Exception\ModuleException;

/**
* Class SetupException
*
* @package Codeception\Module\Percy\Exception
*/
final class SetupException extends Exception
final class SetupException extends ModuleException
{
//
}
3 changes: 2 additions & 1 deletion src/Codeception/Module/Percy/Exchange/CurlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Codeception\Module\Percy\Exchange;

use Codeception\Module\Percy\Exception\ClientException;
use Codeception\Module\Percy;

/**
* Class CurlAdapter
Expand Down Expand Up @@ -62,7 +63,7 @@ public function execute() : string
{
$output = curl_exec($this->resource);
if (curl_errno($this->resource)) {
throw new ClientException(curl_error($this->resource));
throw new ClientException(Percy::MODULE_NAMESPACE, curl_error($this->resource));
}

curl_close($this->resource);
Expand Down

0 comments on commit 445b890

Please sign in to comment.