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
The thing is if a API function returns a value it is always a successful response, because in cause of an error the Error is thrown (ergo the function does not return normally).
try{constresponse=awaitclient.retrieveRefreshTokens(user);if(response.wasSuccessful()){// Always trueconsttoken=response.response.refreshToken;// response.response: RefreshTokenResponseconsterror=response.exception.message;// No compile error, but will throw a `exception is undefined` error}}catch(e){console.log(e);// e is a ClientResponse without response}
So both response and exception properties should be marked as optional:
wasSuccessful can be dropped in this case, because the function either returns something (wasSuccessful = true) or it throws an error (wasSuccessful = false).
As an alternative functions could never throw, but return either ClientResponse<T> or ErrorResponse:
Currently the Client Response is typed as:
The thing is if a API function returns a value it is always a successful response, because in cause of an error the Error is thrown (ergo the function does not return normally).
So both
response
andexception
properties should be marked as optional:But because either the function returns a response or throws an exception they should be the same type:
wasSuccessful
can be dropped in this case, because the function either returns something (wasSuccessful = true
) or it throws an error (wasSuccessful = false
).As an alternative functions could never throw, but return either
ClientResponse<T>
orErrorResponse
:I used types instead of classes because of type-hinting:
The text was updated successfully, but these errors were encountered: