Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add error #64

Merged
merged 1 commit into from
Apr 21, 2022
Merged

feat: add error #64

merged 1 commit into from
Apr 21, 2022

Conversation

lihongxun945
Copy link
Contributor

新增Node Error类

@Genluo
Copy link
Member

Genluo commented Apr 20, 2022

针对错误entity的划分,是否可以考虑类似分层错误,onex-utils关注错误分层,并且针对一些常用的错误类型,可以封装到对应基类中。而业务开发过程,基于onex-utils中BusinessException 、DataBaseException 、等等进行更多的扩展?举例如下:

  • onex-utils中暴露的错误
export class BusinessException extends IndustryError {
  static AldCompleteError(cause: Error) {
    return new BusinessException('阿拉丁补全失败', { cause })
  }

  static InvalidParamsError(cause: Error ) {...}

 }
  • 业务中自定义错误封装
export class IBusinessException extends BusinessException {
  static taskRunningException(cause?: Error) {
    return new BusinessException('TASK_RUNNING_ERROR', cause).setIgnore(false);
  }

  static metaqException(cause?: Error) {
    return new BusinessException('METAQ_ERROR', cause).setIgnore(false);
  }

  static hsfException(cause?: Error) {
    return new BusinessException('HSF_ERROR', cause).setIgnore(false);
  }

  static notFoundException(cause?: Error) {
    return new BusinessException('NOT_FOUND', cause).setIgnore(true);
  }

  static paramsException(cause?: Error) {
    return new BusinessException('PARAMS_ERROR', cause).setIgnore(true);
  }

  static treeException(cause?: Error) {
    return new BusinessException('TREE_ERROR', cause).setIgnore(false);
  }
}
  • 业务错误抛出
try {
  ...
} catch(err) {
 throw IBusinessException.paramsException(err);
}

@Genluo Genluo merged commit f3e7700 into unity-template:master Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants