Restructured code to pass up and handle errors
Pretty big change. Things now pass up errors that can be handled by the caller. This brought about a lot of change. Errors attempt to be descriptive of where they came from and notify user of the api what potentailly caused the error. Also renamed go-halo5-api.go to a more suitable name, http.go. This might change in the future if we implement the http.Client interface
This commit is contained in:
+18
-1
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/dmmcquay/go-halo5-api/halo"
|
||||
@@ -20,6 +21,7 @@ var sampleWarzoneMatchID string = "c35a35f8-f450-4836-a4c2-65100a7acb79"
|
||||
var sampleSeasonID string = "b46c2095-4ca6-4f4b-a565-4702d7cfe586" //February 2016 Season
|
||||
var samplePlaylistID string = "2323b76a-db98-4e03-aa37-e171cfbdd1a4" //SWAT gametype 2016 Season
|
||||
var sampleGameVariantID string = "963ca478-369a-4a37-97e3-432fa13035e1" //Slayer
|
||||
var badGameVariantID string = "9aaaaaaa-369a-4a37-97e3-432fa13035e1" //Slayer
|
||||
var sampleMapVariantsID string = "a44373ee-9f63-4733-befd-5cd8fbb1b44a" //Truth
|
||||
var sampleRequisitionPacksID string = "d10141cb-68a5-4c6b-af38-4e4935f973f7"
|
||||
var sampleRequisitionID string = "e4f549b2-90af-4dab-b2bc-11a46ea44103"
|
||||
@@ -36,7 +38,22 @@ func getAPIKey() string {
|
||||
func main() {
|
||||
|
||||
h := halo.NewHalo(baseurl, title, getAPIKey())
|
||||
fmt.Println(h.Enemies())
|
||||
a, err := h.EmblemImage("smoke721", 512)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(a)
|
||||
b, err := h.SpartanImage("smoke721", 512, "full")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(b)
|
||||
c, err := h.SpartanImage("thisplayerdoesnotexist", 512, "full")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(c)
|
||||
//fmt.Println(h.Enemies())
|
||||
//fmt.Println(h.FlexibleStats())
|
||||
//fmt.Println(h.GameBaseVariants())
|
||||
//fmt.Println(h.Impulses())
|
||||
|
||||
Reference in New Issue
Block a user