updated error handling
This commit is contained in:
parent
898110de47
commit
bbc0b707e8
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/likexian/whois-go"
|
"github.com/likexian/whois-go"
|
||||||
@ -23,12 +24,12 @@ func GetIPInfo(c echo.Context) (ip IP, err error) {
|
|||||||
|
|
||||||
err = ip.CheckIPAddress()
|
err = ip.CheckIPAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return IP{}, err
|
log.Println(fmt.Sprintf("Error checking IP address %s",ip.IP))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ip.GetHostname()
|
err = ip.GetHostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return IP{}, err
|
log.Println(fmt.Sprintf("Error checking revers DNS for IP address %s",ip.IP))
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -39,6 +40,7 @@ func Dip(c echo.Context) (err error) {
|
|||||||
var ip IP
|
var ip IP
|
||||||
|
|
||||||
ip, err = GetIPInfo(c)
|
ip, err = GetIPInfo(c)
|
||||||
|
fmt.Println(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Render(http.StatusInternalServerError, "error.html", nil)
|
return c.Render(http.StatusInternalServerError, "error.html", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user