Skip to content

Research: discover what return values can be changed to CommandResults #244

@IzKuipers

Description

@IzKuipers

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 success boolean to indicate that the operation is successful
  • A successMessage string to optionally inform the invocator what went right
  • A result property that is the result value of the method (type T)
  • An errorMessage string 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 successful CommandResult with value of type T
  • CommandResult.Error<T?> returns an unsuccessful CommandResult with optional error message
  • CommandResult.AxiosError<T?> returns an unsuccessful CommandResult based on the AxiosError from 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.

Metadata

Metadata

Assignees

Labels

RefactoringThis issue refactors a part of the codebaseResearch

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions