Summary
In this chapter, we have looked at the different types of errors that you will encounter while programming, such as syntax, runtime, and semantic errors. We focused more on runtime errors. These errors are more difficult to debug.
We examined the difference between various language philosophies when it comes to dealing with errors. We have seen how Go's syntax for errors is simpler to understand compared to the exception handling that various languages are utilizing.
An error in Go is a value. Values can be passed around to functions. Any error can be a value as long as it implements the error interface type. We learned how easily we can create errors. We also learned that we should name our error values starting with Err
followed by a descriptive camel case name.
Next, we discussed panics and the similarities between a panic and an exception. We also discovered that panics are pretty similar to exceptions; however, if panics are unhandled, they will cause the...