toDRException function

DRException toDRException(
  1. Object error, [
  2. String fallback = LocalErrorCode.networkError
])

把任意异常转成 DRException:已经是的原样返回,其他的记为本地的 fallback。

Implementation

DRException toDRException(Object error, [String fallback = LocalErrorCode.networkError]) {
  if (error is DRException) return error;
  return DRException(code: fallback, message: error.toString(), source: ErrorSource.local, cause: error);
}