Use fatal log instead of panic

This commit is contained in:
dump_stack() 2016-07-25 23:24:25 +03:00
parent 9b657de7b9
commit 69d33189ad

View File

@ -102,24 +102,22 @@ func Get(db *sql.DB, url string) {
utf8, err := charset.NewReader(resp.Body, resp.Header.Get("Content-Type")) utf8, err := charset.NewReader(resp.Body, resp.Header.Get("Content-Type"))
if err != nil { if err != nil {
fmt.Println("Encoding error:", err) log.Fatalln("Encoding error:", err)
return
} }
body, err := ioutil.ReadAll(utf8) body, err := ioutil.ReadAll(utf8)
if err != nil { if err != nil {
fmt.Println("IO error:", err) log.Fatalln("IO error:", err)
return
} }
htmlPage, err := parseLinks(db, body, req) htmlPage, err := parseLinks(db, body, req)
if err != nil { if err != nil {
panic(err) log.Fatalln("Parse links error:", err)
} }
text, err := html2text.FromString(htmlPage) text, err := html2text.FromString(htmlPage)
if err != nil { if err != nil {
panic(err) log.Fatalln("Html to text error:", err)
} }
text += "" text += ""
@ -138,7 +136,7 @@ func Link(db *sql.DB, linkID int64, fromHistory bool) {
} }
if err != nil { if err != nil {
panic(err) log.Fatalln("Get link/history url error:", err)
} }
Get(db, url) Get(db, url)
@ -147,7 +145,7 @@ func Link(db *sql.DB, linkID int64, fromHistory bool) {
func History(db *sql.DB, argAmount, defaultAmount int64, all bool) { func History(db *sql.DB, argAmount, defaultAmount int64, all bool) {
history, err := storage.GetHistory(db) history, err := storage.GetHistory(db)
if err != nil { if err != nil {
panic(err) log.Fatalln("Get history error:", err)
} }
var amount int64 var amount int64