Skip to content

Commit cdf079c

Browse files
authored
Merge pull request #618 from humanmade/db-info
Throw an exception when asking for db information but the container isn't running
2 parents 2a2099e + eda2745 commit cdf079c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

inc/composer/class-command.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ protected function generate_docker_compose( array $args = [] ) : void {
969969
/**
970970
* Return the Database connection details.
971971
*
972+
* @throws \RuntimeException When the database container cannot be found.
972973
* @return array
973974
*/
974975
private function get_db_connection_data() {
@@ -1013,6 +1014,10 @@ private function get_db_connection_data() {
10131014
$ports = shell_exec( sprintf( "$command_prefix docker ps --format '{{.Ports}}' --filter id=%s", $db_container_id ) );
10141015
preg_match( '/([\d.]+):([\d]+)->.*/', trim( $ports ), $ports_matches );
10151016

1017+
if ( empty( $ports_matches ) ) {
1018+
throw new \RuntimeException( 'Could not retrieve information for the database. Is the container running?' );
1019+
}
1020+
10161021
return array_merge(
10171022
array_filter( $values ),
10181023
[

0 commit comments

Comments
 (0)