mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-22 15:06:04 +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"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"mime"
|
"mime"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
nurl "net/url"
|
nurl "net/url"
|
||||||
"os"
|
"os"
|
||||||
fp "path/filepath"
|
fp "path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
|
@ -183,7 +185,19 @@ func createTemplate(filename string, funcMap template.FuncMap) (*template.Templa
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkError(err error) {
|
func checkError(err error) {
|
||||||
if err != nil {
|
if err == nil {
|
||||||
panic(err)
|
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