buildResult method

ModResourceResult<Out> buildResult({
  1. Out? data = null,
  2. int code = -1,
})

Encapsulate build result objects creation to avoid inconsistencies

Implementation

ModResourceResult<Out> buildResult({Out? data = null, int code = -1}) {
  ModResourceResult<Out> res = ModResourceResult();

  res.data = data;
  res.state = res.hasData()? ResourceState.SUCCESS : ResourceState.ERROR;
  res.error = res.isError()? ThirdPartyErrorModel(code: code) : null;

  return res;
}