server icon indicating copy to clipboard operation
server copied to clipboard

[Enhancement]Support for framework exception handler

Open maoxuner opened this issue 3 years ago • 1 comments
trafficstars

All exceptions are catched by Sajya\Server\HandleProcedure::handle without reporting. It will be a better way to use Illuminate\Contracts\Debug\ExceptionHandler to deal with exceptions.

As a benifit of this, all exceptions will be reported, such as logging and instant messaging, most useful for debugging. On the other hand, we can transform them into json-rpc format.

maoxuner avatar Jul 20 '22 15:07 maoxuner

Some ideas about transforming exceptions

First, when an exception was catched in Sajya\Server\HandleProcedure::handle, wrap it with a custom exception, for example WrapException Second, pass WrapException to Illuminate\Contracts\Debug\ExceptionHandler Third, there can be a method named render in WrapException class which transforms common exceptions into json-rpc format Then, ExceptionHandler will call WrapException::render and we get the respone At last, we can return the response directory or handle by Response::makeFromResult or some other

maoxuner avatar Jul 20 '22 15:07 maoxuner