github.com/grokify/go-ringcentral-client@v0.3.31/engagedigital/v1/examples/examplesutils.go (about)

     1  package examples
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"net/http"
     7  
     8  	engagedigital "github.com/grokify/go-ringcentral-client/engagedigital/v1/client"
     9  	"github.com/grokify/mogo/fmt/fmtutil"
    10  )
    11  
    12  func HandleApiResponse(info interface{}, resp *http.Response, err error) {
    13  	if err != nil {
    14  		fmt.Println("E_ERR")
    15  		if resp.StatusCode != 200 {
    16  			fmt.Printf("StatusCode [%v]\n", resp.StatusCode)
    17  			err2 := err.(engagedigital.GenericOpenAPIError)
    18  			fmt.Println(string(err2.Body()))
    19  		}
    20  		log.Fatal(err)
    21  	} else if resp.StatusCode != 200 {
    22  		log.Fatal(resp.StatusCode)
    23  	}
    24  	fmtutil.PrintJSON(info)
    25  }