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
An example of where this could be useful has been implemented in #554 see line 106. This is a temporary workaround which should also be addressed and fixed when implementing this proposal. This case (and many others) could be handled more easily if the error had an error code:
switch(error.code){case4000:
// do something for this error handlingbreak;default:
// do something for general handlingbreak;}
Proposal
Updating ResultObject type to something like this:
exporttypeResult<T>={success: boolean;}&(|{success: true;data: T;}|{success: false;error: string;code?: number;// Optional code parameter added here});exportconstisError=<T>(result: Result<T>): result is {success: false;error: string;code?: number}=>!result.success;exportconstisSuccess=<T>(result: Result<T>): result is {success: true;data: T}=>result.success;exportclassResultObject{staticsuccess<T>(data: T): Result<T>{return{success: true, data };}staticerror<T>(error: string,code?: number): Result<T>{return{success: false,
error,
code,};}}
The text was updated successfully, but these errors were encountered:
Motivation
An example of where this could be useful has been implemented in #554 see line 106. This is a temporary workaround which should also be addressed and fixed when implementing this proposal. This case (and many others) could be handled more easily if the error had an error code:
Proposal
Updating
ResultObject
type to something like this:The text was updated successfully, but these errors were encountered: