Skip to content

Commit

Permalink
Strip the project dir from migration exception
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 1, 2024
1 parent ee8d17f commit 2a3e3d8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions api/Controller/Contao/DatabaseMigrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Contao\ManagerApi\Controller\Contao;

use Contao\ManagerApi\ApiKernel;
use Contao\ManagerApi\HttpKernel\ApiProblemResponse;
use Contao\ManagerApi\Process\ConsoleProcessFactory;
use Contao\ManagerApi\Process\ContaoConsole;
Expand Down Expand Up @@ -39,10 +40,16 @@ class DatabaseMigrationController
*/
private $processFactory;

public function __construct(ContaoConsole $console, ConsoleProcessFactory $processFactory)
/**
* @var ApiKernel
*/
private $kernel;

public function __construct(ContaoConsole $console, ConsoleProcessFactory $processFactory, ApiKernel $kernel)
{
$this->processFactory = $processFactory;
$this->console = $console;
$this->kernel = $kernel;
}

public function __invoke(Request $request): Response
Expand Down Expand Up @@ -194,9 +201,13 @@ private function handleProblems(array $lines, ProcessController $process): Respo
if ('error' === $type && isset($data['message'], $data['file'], $data['line'], $data['trace'])) {
$operations[] = [
'status' => 'error',
'name' => sprintf('Exception in file %s on line %s', $data['file'], $data['line']),
'name' => sprintf(
'Exception in file %s on line %s',
str_replace($this->kernel->getProjectDir().'/', '', $data['file']),
$data['line']
),
'message' => $data['message'],
'trace' => $data['trace'],
'trace' => str_replace($this->kernel->getProjectDir().'/', '', $data['trace']),
];
} else {
$message = explode("\n", $data['message'] ?? '', 2) + ['', ''];
Expand Down

0 comments on commit 2a3e3d8

Please sign in to comment.