Skip to content

Commit

Permalink
move common errors to common place
Browse files Browse the repository at this point in the history
  • Loading branch information
Bai-Yingjie committed Dec 25, 2021
1 parent 0062b49 commit ec11f4d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
3 changes: 0 additions & 3 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"net/url"
"os"
"os/exec"
"runtime"
Expand Down Expand Up @@ -419,8 +418,6 @@ func init() {
as.RegisterType(cmdInfo{})
as.RegisterType(codeRepoAddr{})
as.RegisterType(getFileContent{})
as.RegisterType((*url.Error)(nil))
as.RegisterType((*exec.ExitError)(nil))
as.RegisterType(tryUpdate{})
as.RegisterType((*gshellBin)(nil))
}
14 changes: 14 additions & 0 deletions gshellos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import (
"encoding/hex"
"errors"
"io"
"net"
"net/url"
"os"
"os/exec"
"strings"
"syscall"
"time"

as "github.com/godevsig/adaptiveservice"
)

var (
Expand Down Expand Up @@ -106,3 +111,12 @@ func RunShCmd(cmd string) string {
output, _ := exec.Command("sh", fields...).CombinedOutput()
return string(output)
}

func init() {
as.RegisterType((*net.OpError)(nil))
as.RegisterType((*net.TCPAddr)(nil))
as.RegisterType((*os.SyscallError)(nil))
as.RegisterType(syscall.Errno(0))
as.RegisterType((*url.Error)(nil))
as.RegisterType((*exec.ExitError)(nil))
}
12 changes: 0 additions & 12 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ package gshellos
import (
"fmt"
"io"
"net"
"net/http"
"os"
"syscall"

as "github.com/godevsig/adaptiveservice"
)

func init() {
Expand All @@ -34,10 +29,3 @@ func httpGetFunc(url string) ([]byte, error) {

return body, nil
}

func init() {
as.RegisterType((*net.OpError)(nil))
as.RegisterType((*net.TCPAddr)(nil))
as.RegisterType((*os.SyscallError)(nil))
as.RegisterType(syscall.Errno(0))
}

0 comments on commit ec11f4d

Please sign in to comment.