定制 thesis/exceptionally 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thesis/exceptionally

最新稳定版本:0.3.0

Composer 安装命令:

composer require thesis/exceptionally

包简介

Thesis Exceptionally

README 文档

README

A tiny PHP library that converts errors to exceptions.

Installation

composer require thesis/exceptionally

Requires PHP 8.3+.

Usage

use function Thesis\exceptionally;

// Converts PHP errors to ErrorException
$content = exceptionally(static fn() => file_get_contents('/path/to/file'));

Many PHP functions trigger errors instead of throwing exceptions. This makes error handling inconsistent and cumbersome. exceptionally() wraps a callable and converts any triggered error into a native ErrorException.

Error suppression operator

Errors suppressed with @ are not converted to exceptions:

// Does not throw — the error is suppressed
$content = exceptionally(static fn() => @file_get_contents('/path/to/file'));

Filtering by error level

By default, all levels except E_DEPRECATED and E_USER_DEPRECATED are converted. Deprecations typically come from third-party libraries and should not interrupt execution.

You can specify which levels to convert:

// Convert notices
$result = exceptionally($function, E_USER_NOTICE);

// Convert warnings and notices
$result = exceptionally($function, E_USER_WARNING | E_USER_NOTICE);

// Convert all, including deprecations
$result = exceptionally($function, E_ALL);

License

MIT

统计信息

  • 总下载量: 456
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固