Download the PHP package ufo-tech/rpc-exceptions without Composer

On this page you can find all versions of the php package ufo-tech/rpc-exceptions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rpc-exceptions

ufo-tech/rpc-exceptions

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:

Installation

Requires PHP 8.4 or newer.

Error codes

Code Exception Meaning
-32700 RpcJsonParseException Invalid JSON
-32600 RpcBadRequestException Invalid request
-32601 RpcMethodNotFoundExceptionRpc Unknown method
-32602 RpcBadParamException Invalid parameters
-32603 RpcInternalException Internal error
-32500 RpcRuntimeException Runtime error
-32400 RpcLogicException Logic error
-32401 RpcTokenNotSentException Missing token
-32403 RpcInvalidTokenException Invalid token
-32404 RpcDataNotFoundException Data not found
-32300 RpcAsyncRequestException Invalid async request
-32301 RpcInvalidBatchRequestExceptions Invalid batch
-32099 to -32000 RpcCustomServerException Server error
Outside -32768 to -32000 CustomApplicationException Application error

For other reserved codes, the nearest hundred usually determines the class: -32450 resolves to RpcLogicException. Codes in -32299 to -32100 and -32768 to -32701 resolve to RpcInternalException. The original code is preserved; 0 uses the default (-32603 on the base class). Use codes outside the reserved range for application errors.

The standard JSON-RPC codes are -32700, -32600 to -32603, and -32099 to -32000. Other reserved codes above are defined by this package.

Create an exception

fromCode() selects a class by code. fromArray() and fromJson() read an error response; invalid JSON yields RpcJsonParseException. fromThrowable() creates a new exception and keeps the original as previous by default. It needs an integer code; non-numeric codes such as SQLSTATE must be mapped first. Numeric strings are converted to integers.

Call AbstractRpcErrorException::getMapping() (or getRpcErrorsList()) for the exact mapping.

Application codes

To resolve your own code to a specific class, extend the mapping and call fromCode() on your subclass:

Mapped classes must extend AbstractRpcErrorException and accept (string $message, int $code, ?Throwable $previous) in their constructor. Entries on the left of + take precedence.

Catch by category

Interface Error type
IUserInputExceptionInterface Invalid input, method, parameters, async request or batch
ISecurityExceptionInterface Authentication or authorization failure
IServerExceptionInterface RPC or server failure
IProcedureExceptionInterface Application-defined procedure error

The category follows the resolved class. RpcLogicException and RpcRuntimeException are server errors.

Extra data

Package exceptions carry an optional data bag:

changeExtraData() replaces the bag; pushToExtraData() merges into it. Both return the exception. Only scalar values, null, and nested arrays are kept. Pass acyclic arrays: circular references can exhaust memory.

fromThrowable() copies the bag. fromArray() and fromJson() restore it from extra or data.extra:

Error responses

ExceptionToArrayTransformer formats a throwable for an RPC response. Only dev and test include the full dump; other environments include the class alone. The extra key appears only when the bag is not empty.

getFullInfo() and getShortInfo() select a format directly. Nested previous exceptions still use infoByEnvironment(). The reported code is preserved when convertible to a nonzero integer; otherwise it falls back to -32603.

For constraint errors, ConstraintsImposedException extends -32602 and takes the constraint list as its second argument:


All versions of rpc-exceptions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-ctype Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ufo-tech/rpc-exceptions contains the following files

Loading the files please wait ...