-
Notifications
You must be signed in to change notification settings - Fork 0
Description
As a refresher; the CommandResult class is a class that allows us to return either a success or error state with a single return type. CommandResult has:
- A
successboolean to indicate that the operation is successful - A
successMessagestring to optionally inform the invocator what went right - A
resultproperty that is the result value of the method (typeT) - An
errorMessagestring to optionally inform the invocator what went wrong
CommandResult also has a number of static methods used to easily return from a method:
CommandResult.Ok<T?>returns a successfulCommandResultwith value of typeTCommandResult.Error<T?>returns an unsuccessfulCommandResultwith optional error messageCommandResult.AxiosError<T?>returns an unsuccessfulCommandResultbased on theAxiosErrorfrom an Axios call
This issue researches the various ArcOS methods that we can convert to using CommandResult as the return value. Some methods currently return strings such as success or err_noExist, but these can easily be converted to CommandResults so that it's easier for the invocator to know what went wrong instead of relying on a Record<T, string> somewhere that contains captions that correspond to the result string.
One example of this is ServiceChangeResult, a string that indicates what went wrong or right when stopping or starting a service. This can be easily converted to a CommandResult so that we can get rid of the ServiceChangeResultCaptions constant.