Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 502e17a

Browse files
mustafaakindavecheney
authored andcommitted
Syntax coloring for Readme
I think it helps readability.
1 parent 0d62637 commit 502e17a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Package errors implements functions for manipulating errors.
44

55
The traditional error handling idiom in Go is roughly akin to
6-
```
6+
```go
77
if err != nil {
88
return err
99
}
@@ -13,7 +13,7 @@ which applied recursively up the call stack results in error reports without con
1313
## Adding context to an error
1414

1515
The errors.Wrap function returns a new error that adds context to the original error. For example
16-
```
16+
```go
1717
_, err := ioutil.ReadAll(r)
1818
if err != nil {
1919
return errors.Wrap(err, "read failed")
@@ -24,13 +24,13 @@ In addition, `errors.Wrap` records the file and line where it was called, allowi
2424
## Retrieving the cause of an error
2525

2626
Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to recurse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
27-
```
27+
```go
2828
type causer interface {
2929
Cause() error
3030
}
3131
```
3232
`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:
33-
```
33+
```go
3434
switch err := errors.Cause(err).(type) {
3535
case *MyError:
3636
// handle specifically

0 commit comments

Comments
 (0)