[Go2ErrorHandling] Go should support Exception handler

Exception handling has many advantages over return-value-based error reporting. Good framework design helps the application developer realize the benefits of exceptions. 

I write this post is about to against the official go2 error handler design. At the official design. it introduce new Check/Handler section.

Which looks very strange. In go 1. we have many if err != nil, in Go 2 , we will have many check/Handler?


No, we should stop Strange design。

The handler and check not match , you have to write a lot check , check check, and define lot's of handler.
This stupid idea.

for Exception handler,
you can

Try {} catch (NullPointException e) {  //TODO: handler Null Point errors } catch (OverflowException e) {  //TODO handler Overflow errors}

Very clean and tidy.

did you see it ?


Let's back to see go2 design paper, Check for what? handler what?

nothing to know, no problem resolved. you just make things worse and worse

 I would like to suggest some good error handling

  1. C# https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/
  2. F# https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/exception-handling/

these two exception handling design , provided us a clean interface, and easy to deal , easy to track problems.

the Go2Draf handler Check seems too complicated and not well structed

And here some other article talk about exception handler, very well document .



分类: 默认 标签: 发布于: 2018, 点击数: