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

程序之异常处理 #11

Open
gzqby opened this issue Nov 14, 2021 · 0 comments
Open

程序之异常处理 #11

gzqby opened this issue Nov 14, 2021 · 0 comments

Comments

@gzqby
Copy link
Owner

gzqby commented Nov 14, 2021

异常处理-软件工程最值得考量的一部份之一(甚至golang因异常处理方式不够优雅而受人诟病)

各种各样的编程语言,各种各样的错误形式,放在一起以表现形式分类,才能恰到好处:
  1. 重大异常

    物理因素等,无法处理

    1. 内存耗尽
    2. 栈溢出
    3. 等各种程序无能为力的异常
  2. 一般异常

    1. 程序明显逻辑问题的异常

      不捕获,抛出来,让开发者发现问题

      1. 数据库IP错误,无法连接
      2. Null读取值
      3. 类型错误
    2. 程序可处理的意外情况

      需要捕获异常,属于正常发生的不正常情况

      1. 查询文件找不到
      2. 前端网络错误

综上,处理方式可分为三类,无法处理着重关注;不处理可程序退出让开发者明确;多兜底防止程序退出

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

No branches or pull requests

1 participant