mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-05 21:11:02 +02:00
fixed error handling
This commit is contained in:
parent
482c9dc5f6
commit
fb3099169e
40
main.go
40
main.go
@ -39,9 +39,9 @@ const (
|
||||
)
|
||||
|
||||
// CheckError makes error handling not as ugly and inefficient.
|
||||
func CheckError(e error) {
|
||||
if e != nil {
|
||||
log.Fatal("WiiSOAP forgot how to drive and suddenly crashed! Reason: ", e)
|
||||
func CheckError(err error) {
|
||||
if err != nil {
|
||||
log.Fatalf("WiiSOAP forgot how to drive and suddenly crashed! Reason: %s\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func main() {
|
||||
CheckError(err)
|
||||
|
||||
// Start the HTTP server.
|
||||
fmt.Printf("Starting HTTP connection (%s)...\nNot using the usual port for HTTP? Be sure to use a proxy, otherwise the Wii can't connect!", CON.Address)
|
||||
fmt.Printf("Starting HTTP connection (%s)...\nNot using the usual port for HTTP?\nBe sure to use a proxy, otherwise the Wii can't connect!\n", CON.Address)
|
||||
http.HandleFunc("/", handler) // each request calls handler
|
||||
log.Fatal(http.ListenAndServe(CON.Address, nil))
|
||||
|
||||
@ -97,9 +97,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "CheckDeviceStatus":
|
||||
fmt.Println("CDS.")
|
||||
CDS := CDS{}
|
||||
if err = xml.Unmarshal(body, &CDS); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &CDS); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)")
|
||||
fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;3")
|
||||
return
|
||||
}
|
||||
fmt.Println(CDS)
|
||||
@ -131,9 +131,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "NotifiedETicketsSynced":
|
||||
fmt.Println("NETS")
|
||||
NETS := NETS{}
|
||||
if err = xml.Unmarshal(body, &NETS); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &NETS); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;)")
|
||||
fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;3")
|
||||
fmt.Printf("error: %v", err)
|
||||
return
|
||||
}
|
||||
@ -159,9 +159,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "ListETickets":
|
||||
fmt.Println("LET")
|
||||
LET := LET{}
|
||||
if err = xml.Unmarshal(body, &LET); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &LET); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;)")
|
||||
fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;3")
|
||||
fmt.Printf("error: %v", err)
|
||||
return
|
||||
}
|
||||
@ -190,9 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "PurchaseTitle":
|
||||
fmt.Println("PT")
|
||||
PT := PT{}
|
||||
if err = xml.Unmarshal(body, &PT); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &PT); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;)")
|
||||
fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;3")
|
||||
fmt.Printf("Error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
@ -232,9 +232,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "CheckRegistration":
|
||||
fmt.Println("CR.")
|
||||
CR := CR{}
|
||||
if err = xml.Unmarshal(body, &CR); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &CR); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "not good enough for me. ;)")
|
||||
fmt.Fprint(w, "not good enough for me. ;3")
|
||||
fmt.Printf("Error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
@ -262,9 +262,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "GetRegistrationInfo":
|
||||
fmt.Println("GRI.")
|
||||
GRI := GRI{}
|
||||
if err = xml.Unmarshal(body, &GRI); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &GRI); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "how dirty. ;)")
|
||||
fmt.Fprint(w, "how dirty. ;3")
|
||||
fmt.Printf("Error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
@ -298,9 +298,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "Register":
|
||||
fmt.Println("REG.")
|
||||
REG := REG{}
|
||||
if err = xml.Unmarshal(body, ®); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, ®); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "disgustingly invalid. ;)")
|
||||
fmt.Fprint(w, "disgustingly invalid. ;3")
|
||||
fmt.Printf("Error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
@ -331,9 +331,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
case "Unregister":
|
||||
fmt.Println("UNR.")
|
||||
UNR := UNR{}
|
||||
if err = xml.Unmarshal(body, &UNR); os.IsExist(err) {
|
||||
if err = xml.Unmarshal(body, &UNR); err != nil {
|
||||
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
|
||||
fmt.Fprint(w, "how abnormal... ;)")
|
||||
fmt.Fprint(w, "how abnormal... ;3")
|
||||
fmt.Printf("Error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user