Pull request: all: imp code, err handling
Closes #2571. Squashed commit of the following: commit a5b50ee011a995f4ab3d93314acd6f0ca82d99cf Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Mar 15 14:05:25 2021 +0300 all: imp code commit bc610f8f438549e8c6b04c8a213b5422dda2aff5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Mar 12 20:00:14 2021 +0300 all: imp code, err handling
This commit is contained in:
@@ -4,6 +4,7 @@ package dhcpd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
@@ -39,9 +40,10 @@ func (s *Server) dbLoad() {
|
||||
|
||||
data, err := ioutil.ReadFile(s.conf.DBFilePath)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.Error("DHCP: can't read file %s: %v", s.conf.DBFilePath, err)
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
log.Error("dhcp: can't read file %q: %v", s.conf.DBFilePath, err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -508,8 +508,8 @@ func (s *Server) handleReset(w http.ResponseWriter, r *http.Request) {
|
||||
s.Stop()
|
||||
|
||||
err := os.Remove(s.conf.DBFilePath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
log.Error("DHCP: os.Remove: %s: %s", s.conf.DBFilePath, err)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Error("dhcp: removing %q: %s", s.conf.DBFilePath, err)
|
||||
}
|
||||
|
||||
oldconf := s.conf
|
||||
|
||||
Reference in New Issue
Block a user