Skip to content

Commit 9c175f6

Browse files
Jimmy99jameswpm
authored andcommitted
Update 11.1.md
typographical errors and improved readability
1 parent d76dcb0 commit 9c175f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

en/11.1.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The error's `Offset` field will not be printed at runtime when syntax errors occ
7676
return err
7777
}
7878

79-
It should be noted that when the function returns a custom error, the return value is set to the recommend type of error rather than a custom error type. Be careful not to pre-declare variables of custom error types. For example:
79+
It should be noted that when the function returns a custom error, the return value is set to the recommended type of error rather than a custom error type. Be careful not to pre-declare variables of custom error types. For example:
8080

8181
func Decode() *SyntaxError {
8282
// error, which may lead to the caller's err != nil comparison to always be true.
@@ -112,7 +112,7 @@ Using type assertion, we can check whether or not our error is of type net.Error
112112

113113
## Error handling
114114

115-
Go handles errors and checks the return values of functions in a C-like fashion, which is different than what most of the other major languages do. This makes the code more explicit and predictable, but also more verbose. To reduce the redundancy of our error-handling code, we can use abstract error handling functions that allow us to implement similar error handling behaviour:
115+
Go handles errors and checks the return values of functions in a C-like fashion, which is different to how most of the other major languages do. This makes the code more explicit and predictable, but also more verbose. To reduce the redundancy of our error-handling code, we can use abstract error handling functions that allow us to implement similar error handling behaviour:
116116

117117
func init() {
118118
http.HandleFunc("/view", viewRecord)
@@ -131,7 +131,7 @@ Go handles errors and checks the return values of functions in a C-like fashion,
131131
}
132132
}
133133

134-
The above example demonstrate access to data and template call has detected error when an error occurs , call a unified handler http.Error, returns a 500 error code to the client , and display the corresponding error data. But when more and more HandleFunc join, so error-handling logic code will be more and more, in fact, we can customize the router to reduce code (refer to realize the idea of ​​the third chapter of HTTP Detailed).
134+
The above example demonstrate how the data access and template call has detected an error. When an error occurs , a call to unified handler http.Error, returns a 500 error code to the client , and displays the corresponding error data. But when more and more HandleFunc calls are made, so error-handling logic code will increase. We can customize the router to reduce code (refer to the third chapter of HTTP for more detail).
135135

136136
type appHandler func(http.ResponseWriter, *http.Request) error
137137

0 commit comments

Comments
 (0)