server
server copied to clipboard
[Enhancement]Support for framework exception handler
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.
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