Files
coolify/app/Exceptions/DeploymentException.php
T
Andras BacsaiandClaude Opus 5.5 129cc97047 fix(previews): remove only the preview's own networks and volumes
- Deleting a Docker Compose preview removed every top-level network
  and volume named in the compose file, so it could disconnect
  coolify-proxy from the coolify network or a shared proxy network and
  delete a shared named volume. It now removes only the network and
  volumes that Coolify generated for that preview, and a network only
  when no other container uses it.
- A deployment that stops with an explained error (unsafe compose,
  missing secret keys, invalid build variable names) shows the
  explanation once, followed by "Deployment failed.".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 14:37:21 +02:00

52 lines
1.5 KiB
PHP

<?php
namespace App\Exceptions;
use Exception;
/**
* Exception for expected deployment failures caused by user/application errors.
* These are not Coolify bugs and should not be logged to laravel.log.
* Examples: Nixpacks detection failures, missing Dockerfiles, invalid configs, etc.
*/
class DeploymentException extends Exception
{
private bool $messageAlreadyLogged = false;
/**
* Create a new deployment exception instance.
*
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
/**
* Create from another exception, preserving its message and stack trace.
*/
public static function fromException(\Throwable $exception): static
{
return new static($exception->getMessage(), $exception->getCode(), $exception);
}
/**
* Create an exception for a message that is already a visible line in the deployment log,
* so the failure handler does not show the same explanation again.
*/
public static function alreadyLogged(string $message, int $code = 0, ?\Throwable $previous = null): static
{
$exception = new static($message, $code, $previous);
$exception->messageAlreadyLogged = true;
return $exception;
}
public function isMessageAlreadyLogged(): bool
{
return $this->messageAlreadyLogged;
}
}