承接 ufo-tech/rpc-exceptions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ufo-tech/rpc-exceptions

Composer 安装命令:

composer require ufo-tech/rpc-exceptions

包简介

Exception package RPC server error codes

README 文档

README

Exception package RPC server error codes

Ukraine

License Size package_version fork php_version

Problem

When a rpc call encounters an error, the Response Object MUST contain the error member with a value that is a Object with the following members:

  • code: A Number that indicates the error type that occurred. This MUST be an integer.

  • message: A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.

Code Type error Summary
-32700 Parse error Invalid JSON was received by the server
-32600 Invalid Request The JSON sent is not a valid Request object.
-32601 Method not found The method does not exist / is not available.
-32602 Invalid params Invalid method parameter(s).
-32603 Internal error Internal JSON-RPC error.
-32500 Server error Runtime error on procedure.
-32400 System error Logic error on application.
-32401 Security error Token not found
-32403 Security error Invalid token
-32404 Data error Requested data not found
-32300 Async error Error transfer async data
-32301 Batch error Error batch request
-32000 Application error Reserved for implementation-defined server-errors.
from -32001 to -32099 Custom user exception ---

There are many error codes and identifying the error from the code can be a difficult task. This library will help you. You can easily get the exception object from the error code.

Code Exception class
-32700 RpcJsonParseException::class
-32600 RpcBadRequestException::class
-32601 RpcMethodNotFoundExceptionRpc::class
-32602 RpcBadParamException::class
-32603 RpcInternalException::class
-32500 RpcRuntimeException::class
-32400 RpcLogicException::class
-32401 RpcTokenNotFoundInHeaderException::class
-32403 RpcInvalidTokenException::class
-32404 RpcDataNotFoundException::class
-32300 RpcAsyncRequestException::class
-32301 RpcInvalidBatchRequestExceptions::class
-32000 RpcCustomApplicationException::class
from -32001 to -32099" ---

Installation

$ composer require ufo-tech/rpc-exceptions

Get exception object

From code

use Ufo\RpcError\AbstractRpcErrorException;

$code = -32700;
$message = 'Some custom error message from rpc server'; // optional
$rpcException = AbstractRpcErrorException::fromCode($code);
// return instance of RpcJsonParseException::class

From array

use Ufo\RpcError\AbstractRpcErrorException;

$data = [
    'code' = -32600,
    'message' = 'Some custom error message from rpc server',
];
$rpcException = RpcBadRequestException::fromArray($data);
// return instance of RpcBadRequestException::class

From json

use Ufo\RpcError\AbstractRpcErrorException;

$data = "{\"code\":-32500,\"message\":\"Some custom error message from rpc server\"}";
$rpcException = AbstractRpcErrorException::fromArray($data);
// return instance of RpcRuntimeException::class

Mapping list

use Ufo\RpcError\AbstractRpcErrorException;

$mapping = AbstractRpcErrorException::getRpcErrorsList();
// return array map
[
    -32700 => RpcJsonParseException::class,
    -32600 => RpcBadRequestException::class,
    -32601 => RpcMethodNotFoundExceptionRpc::class,
    -32602 => RpcBadParamException::class,
    -32603 => RpcInternalException::class,
    -32500 => RpcRuntimeException::class,
    -32400 => RpcLogicException::class,
    -32401 => RpcTokenNotFoundInHeaderException::class,
    -32403 => RpcInvalidTokenException::class,
    -32404 => RpcDataNotFoundException::class,
    -32300 => RpcAsyncRequestException::class,
    -32301 => RpcInvalidBatchRequestExceptions::class,
    -32000 => RpcCustomApplicationException::class,
]

Profit

ufo-tech/rpc-exceptions 适用场景与选型建议

ufo-tech/rpc-exceptions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.57k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rpc」 「errors」 「api」 「json-rpc」 「Ufo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ufo-tech/rpc-exceptions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ufo-tech/rpc-exceptions 我们能提供哪些服务?
定制开发 / 二次开发

基于 ufo-tech/rpc-exceptions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 21
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-31