Skip to content

Improvement: Standardized all exception messages in SiteContainers.php #1898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions php/EE/Migration/SiteContainers.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function backup_site_docker_compose_file( $source_path, $destinati
EE::debug( 'Start backing up site\'s docker-compose.yml' );
$fs = new Filesystem();
if ( ! $fs->exists( $source_path ) ) {
throw new \Exception( ' site\'s docker-compose.yml does not exist' );
throw new \Exception( "Site's docker-compose.yml does not exist at {$source_path}" );
}
$fs->copy( $source_path, $destination_path, true );
EE::debug( 'Complete backing up site\'s docker-compose.yml' );
Expand All @@ -54,7 +54,7 @@ public static function revert_site_docker_compose_file( $source_path, $destinati
EE::debug( 'Start restoring site\'s docker-compose.yml' );
$fs = new Filesystem();
if ( ! $fs->exists( $source_path ) ) {
throw new \Exception( ' site\'s docker-compose.yml.backup does not exist' );
throw new \Exception( "Site's docker-compose.yml does not exist at {$source_path}" );
}
$fs->copy( $source_path, $destination_path, true );
$fs->remove( $source_path );
Expand Down Expand Up @@ -137,11 +137,11 @@ public static function disable_default_containers( $site_info ) {
EE::debug( "Start disabling default containers of ${site_info['site_url']}" );

if ( ! chdir( $site_info['site_fs_path'] ) ) {
throw new \Exception( sprintf( '%s path does not exist', $site_info['site_fs_path'] ) );
throw new \Exception( "Path does not exist: {$site_info['site_fs_path']}" );
}

if ( ! EE::exec( 'docker-compose stop && docker-compose rm -f' ) ) {
throw new \Exception( sprintf( 'Something went wrong on disable site %s', $site_info['site_url'] ) );
throw new \Exception( "Failed to disable site {$site_info['site_url']}" );
}

EE::debug( "Complete disabling default containers of ${site_info['site_url']}" );
Expand Down Expand Up @@ -219,7 +219,7 @@ public static function reload_nginx( $site_fs_path ) {
chdir( $site_fs_path );
$success = EE::exec( "docker-compose exec nginx sh -c 'nginx -t && nginx -s reload'" );
if ( ! $success ) {
throw new \Exception( 'Could not reload nginx. Check logs.' );
throw new \Exception( "Could not reload nginx for site at {$site_fs_path}. Check logs." );
}
}

Expand All @@ -233,7 +233,7 @@ public static function reload_php( $site_fs_path ) {
chdir( $site_fs_path );
$success = EE::exec( "docker-compose exec php bash -c 'kill -USR2 1'" );
if ( ! $success ) {
throw new \Exception( 'Could not reload php. Check logs.' );
throw new \Exception( "Could not reload PHP for site at {$site_fs_path}. Check logs." );
}
}

Expand All @@ -247,7 +247,7 @@ public static function docker_compose_pull( $site_fs_path ) {
chdir( $site_fs_path );
$success = EE::exec( "docker-compose pull" );
if ( ! $success ) {
throw new \Exception( 'Could pull given images.' );
throw new \Exception( "Could not pull site Docker images at {$site_fs_path}" );
}
}

Expand Down