fix: check error type on file not found (#2383)

pull/2413/head
BoYanZh 2022-11-18 01:30:37 +08:00 committed by GitHub
parent 8beeba7c0c
commit a02d9c8463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package static
import (
"errors"
"fmt"
"io/fs"
"net/http"
@ -18,7 +19,7 @@ import (
func InitIndex() {
index, err := public.Public.ReadFile("dist/index.html")
if err != nil {
if err == fs.ErrNotExist {
if errors.Is(err, fs.ErrNotExist) {
utils.Log.Fatalf("index.html not exist, you may forget to put dist of frontend to public/dist")
}
utils.Log.Fatalf("failed to read index.html: %v", err)