You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the latest version of webrpc there was added a selection of errors that extend from the WebRpcError class, as well as ways of defining Custom errors like UserNotFoundError. Which we can now use instanceof to handle different error cases easier. This is a great but im wondering if there is room for improvement by exposing which errors can be returned by a function so that our userland error handling code can exhuastively handle each case.
A current weakness of typescript is lack of a way to specify which errors may be thrown from a function. See discussion for possible function throws clause going back to 2016 and Ryans final word of the subject and rejection. Without typescript support for thrown errors we can however "lift" a thrown error and return it in a Result<T, E> type eg.
Currently we don't have a way to distinguish what errors can be returned by individual RPC endpoints. We define custom errors in RIDL globally and not per RPC method.
I see how useful it could be to tell what errors you can get from individual RPC method. However, I don't see how we could implement this.
Would Result<GetUserByAddressReturn, WebRpcError> be any helpful?
In the latest version of webrpc there was added a selection of errors that extend from the
WebRpcError
class, as well as ways of defining Custom errors likeUserNotFoundError
. Which we can now useinstanceof
to handle different error cases easier. This is a great but im wondering if there is room for improvement by exposing which errors can be returned by a function so that our userland error handling code can exhuastively handle each case.A current weakness of typescript is lack of a way to specify which errors may be thrown from a function. See discussion for possible function
throws
clause going back to 2016 and Ryans final word of the subject and rejection. Without typescript support for thrown errors we can however "lift" a thrown error and return it in aResult<T, E>
type eg.Above the function is able to specify which errors it will potentially return:
Result<GetUserByAddressReturn, WebRpcError | UserNotFoundError>
References:
The text was updated successfully, but these errors were encountered: