exception() php,PHP Exception

LogicException

Exception that represents error in the program logic. This kind of exception should lead directly to a fix in your code.

代码里必须解决的异常

节选开源代码/**

* Static shortcut to \Mockery\Container::self().

*

* @throws LogicException

*

* @return \Mockery\MockInterface

*/

public static function self()

{

if (is_null(self::$_container)) {

throw new \LogicException('You have not declared any mocks yet');

}

return self::$_container->self();

}

RuntimeException

Exception thrown if an error which can only be found on runtime occurs.

无法避免的异常

UnexpectedValueExceptionprotected function write(array $record)

{

if (!is_resource($this->stream)) {

if (null === $this->url || '' === $this->url) {

throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');

}

$this->createDir();

$this->errorMessage = null;

set_error_handler(array($this, 'customErrorHandler'));

$this->stream = fopen($this->url, 'a');

if ($this->filePermission !== null) {

@chmod($this->url, $this->filePermission);

}

restore_error_handler();

if (!is_resource($this->stream)) {

$this->stream = null;

throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));

}

}

if ($this->useLocking) {

// ignoring errors here, there's not much we can do about them

flock($this->stream, LOCK_EX);

}

fwrite($this->stream, (string) $record['formatted']);

if ($this->useLocking) {

flock($this->stream, LOCK_UN);

}

}

Lists of Throwable and Exception tree as of 7.2.0Error

ArithmeticError

DivisionByZeroError

AssertionError

ParseError

TypeError

ArgumentCountError

Exception

ClosedGeneratorException

DOMException

ErrorException

IntlException

LogicException

BadFunctionCallException

BadMethodCallException

DomainException

InvalidArgumentException

LengthException

OutOfRangeException

PharException

ReflectionException

RuntimeException

OutOfBoundsException

OverflowException

PDOException

RangeException

UnderflowException

UnexpectedValueException

SodiumException

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值