Skip to content

Commit 88bf2d2

Browse files
committed
[-] reordered the badges for consistency across projects
[-] added log output of the sample program
1 parent ce7f78d commit 88bf2d2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<p align="center"><img src="https://user-images.githubusercontent.com/1092882/87815217-d864a680-c882-11ea-9c94-24b67f7125fe.png" alt="errors gopher" width="256px"/></p>
22

3-
[![](https://godoc.org/github.com/nathany/looper?status.svg)](https://pkg.go.dev/github.com/bnkamalesh/errors?tab=doc)
4-
[![Maintainability](https://api.codeclimate.com/v1/badges/a86629ab167695d4db7f/maintainability)](https://codeclimate.com/github/bnkamalesh/errors)
5-
[![Go Report Card](https://goreportcard.com/badge/github.com/bnkamalesh/errors)](https://goreportcard.com/report/github.com/bnkamalesh/errors)
63
[![Build Status](https://travis-ci.org/bnkamalesh/errors.svg?branch=master)](https://travis-ci.org/bnkamalesh/errors)
74
[![codecov](https://codecov.io/gh/bnkamalesh/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/bnkamalesh/errors)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/bnkamalesh/errors)](https://goreportcard.com/report/github.com/bnkamalesh/errors)
6+
[![Maintainability](https://api.codeclimate.com/v1/badges/a86629ab167695d4db7f/maintainability)](https://codeclimate.com/github/bnkamalesh/errors)
7+
[![](https://godoc.org/github.com/nathany/looper?status.svg)](https://pkg.go.dev/github.com/bnkamalesh/errors?tab=doc)
88

99
# Errors
1010

@@ -16,6 +16,10 @@ Errors package is a drop-in replacement of the built-in Go errors package with n
1616

1717
In case of nested errors, the messages (in case of nesting with this package's error) & errors are also looped through.
1818

19+
### Prerequisites
20+
21+
Go 1.13+
22+
1923
### Custom error types
2024

2125
1. TypeInternal - is the error type for when there is an internal system error. e.g. Database errors
@@ -78,7 +82,6 @@ package main
7882

7983
import (
8084
"fmt"
81-
"log"
8285
"net/http"
8386
"time"
8487

@@ -111,7 +114,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
111114
err := foo()
112115
if err != nil {
113116
// log the error on your server for troubleshooting
114-
log.Println(err.Error())
117+
fmt.Println(err.Error())
115118
// respond to request with friendly msg
116119
status, msg, _ := errors.HTTPStatusCodeMessage(err)
117120
webgo.SendError(w, msg, status)
@@ -155,7 +158,12 @@ Since we get the status code and message separately, when using any web framewor
155158
Once the app is running, you can check the response by opening `http://localhost:8080` on your browser. Or on terminal
156159
```bash
157160
$ curl http://localhost:8080
158-
{"errors":"we lost bar2!. bar2 was deceived by bar1 :(","status":500} // output/response
161+
{"errors":"we lost bar2!. bar2 was deceived by bar1 :(","status":500} // HTTP response
162+
```
163+
164+
And output of the `fmt.Println(err.Error())`
165+
```bash
166+
/Users/username/go/src/errorscheck/main.go:28 /Users/username/go/src/errorscheck/main.go:20 sinking bar
159167
```
160168

161169
## Contributing

0 commit comments

Comments
 (0)