mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-10 17:36:02 +08:00
Fix: stop panic on TCP broken pipe
This commit is contained in:
parent
3d12d6170b
commit
8ac455b307
1 changed files with 16 additions and 2 deletions
|
@ -11,11 +11,13 @@ import (
|
|||
"io/ioutil"
|
||||
"math"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
nurl "net/url"
|
||||
"os"
|
||||
fp "path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
|
@ -183,7 +185,19 @@ func createTemplate(filename string, funcMap template.FuncMap) (*template.Templa
|
|||
}
|
||||
|
||||
func checkError(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for a broken connection, as it is not really a
|
||||
// condition that warrants a panic stack trace.
|
||||
if ne, ok := err.(*net.OpError); ok {
|
||||
if se, ok := ne.Err.(*os.SyscallError); ok {
|
||||
if se.Err == syscall.EPIPE || se.Err == syscall.ECONNRESET {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue