Add simple output handling to exception classes

This commit is contained in:
crazywhalecc 2026-02-28 13:43:28 +08:00
parent d316684995
commit 2d550a8db4
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
4 changed files with 24 additions and 3 deletions

View File

@ -7,4 +7,7 @@ namespace StaticPHP\Exception;
/**
* Exception caused by manual intervention.
*/
class InterruptException extends SPCException {}
class InterruptException extends SPCException
{
protected bool $simple_output = true;
}

View File

@ -4,4 +4,7 @@ declare(strict_types=1);
namespace StaticPHP\Exception;
class RegistryException extends SPCException {}
class RegistryException extends SPCException
{
protected bool $simple_output = true;
}

View File

@ -20,6 +20,8 @@ use StaticPHP\Package\TargetPackage;
*/
abstract class SPCException extends \Exception
{
protected bool $simple_output = false;
/** @var null|array Package information */
private ?array $package_info = null;
@ -155,6 +157,16 @@ abstract class SPCException extends \Exception
return $this->extra_log_files;
}
public function isSimpleOutput(): bool
{
return $this->simple_output;
}
public function setSimpleOutput(bool $simple_output = true): void
{
$this->simple_output = $simple_output;
}
/**
* Load stack trace information to detect Package, Builder, and Installer context.
*/

View File

@ -10,4 +10,7 @@ namespace StaticPHP\Exception;
* This exception is used to indicate that the SPC is being used incorrectly.
* Such as when a command is not supported or an invalid argument is provided.
*/
class WrongUsageException extends SPCException {}
class WrongUsageException extends SPCException
{
protected bool $simple_output = true;
}