定制 qubus/error 二次开发

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

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

qubus/error

最新稳定版本:v3.0.1

Composer 安装命令:

composer require qubus/error

包简介

Package for Error handling.

README 文档

README

Error handling with PSR-3 logging for catching exceptions as well as errors. There is also an error class to use as an alternative to throwing an exception.

Example

use Qubus\Error\Error;

use function Qubus\Error\Helpers\is_error;

function get_current_user(string|int $id = null)
{
    if(null === $id) {
        return new Error('User id cannot be null.');
    }
}

$user = get_current_user('56');

if(is_error($user)) {
    // log error message or send error flash message back to the user.
}

Requirements

  • PHP 8.4+

Installation

$ composer require qubus/error

Exceptions vs. Errors

There is a healthy discussion among developers whether to use exceptions or error return codes. There are pros and cons to both sides. No matter what side you fall on, the articles below are a great read with a dose of great examples as to the proper use of exceptions.

Author Statement

I am of the mind that if a function is to return something, then it should return, not throw. If an exception is exceptional, it should be caught and logged. I know that I don't do this perfectly, but it is my goal to go through all of my code and make sure that exceptions are exceptional and not unexceptional.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固