mirror of
https://github.com/ViViDboarder/docset-sfdc.git
synced 2024-11-21 23:16:33 +00:00
Improve logging a bit
This commit is contained in:
parent
9b268fb293
commit
86d554f10a
@ -34,13 +34,13 @@ func NewFormatedError(format string, a ...interface{}) error {
|
|||||||
|
|
||||||
// NewTypeNotFoundError returns an error for a TOCEntry with an unknown type
|
// NewTypeNotFoundError returns an error for a TOCEntry with an unknown type
|
||||||
func NewTypeNotFoundError(entry TOCEntry) error {
|
func NewTypeNotFoundError(entry TOCEntry) error {
|
||||||
return NewFormatedError("Type not found : %s %s", entry.Text, entry.ID)
|
return NewFormatedError("Type not found: %s %s", entry.Text, entry.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExitIfError is a helper function for terminating if an error is not nil
|
// ExitIfError is a helper function for terminating if an error is not nil
|
||||||
func ExitIfError(err error) {
|
func ExitIfError(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ERROR :", err)
|
fmt.Println("ERROR: ", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,6 +48,6 @@ func ExitIfError(err error) {
|
|||||||
// WarnIfError is a helper function for terminating if an error is not nil
|
// WarnIfError is a helper function for terminating if an error is not nil
|
||||||
func WarnIfError(err error) {
|
func WarnIfError(err error) {
|
||||||
if err != nil && shouldWarn {
|
if err != nil && shouldWarn {
|
||||||
fmt.Println("WARNING :", err)
|
fmt.Println("WARNING: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,16 +42,12 @@ func parseFlags() (locale string, deliverables []string, silent bool) {
|
|||||||
func getTOC(locale string, deliverable string) (toc *AtlasTOC, err error) {
|
func getTOC(locale string, deliverable string) (toc *AtlasTOC, err error) {
|
||||||
var tocURL = fmt.Sprintf("https://developer.salesforce.com/docs/get_document/atlas.%s.%s.meta", locale, deliverable)
|
var tocURL = fmt.Sprintf("https://developer.salesforce.com/docs/get_document/atlas.%s.%s.meta", locale, deliverable)
|
||||||
resp, err := http.Get(tocURL)
|
resp, err := http.Get(tocURL)
|
||||||
if err != nil {
|
ExitIfError(err)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the downloaded JSON
|
// Read the downloaded JSON
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
contents, err := ioutil.ReadAll(resp.Body)
|
contents, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
ExitIfError(err)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load into Struct
|
// Load into Struct
|
||||||
toc = new(AtlasTOC)
|
toc = new(AtlasTOC)
|
||||||
@ -64,7 +60,7 @@ func verifyVersion(toc *AtlasTOC) error {
|
|||||||
currentVersion := toc.Version.DocVersion
|
currentVersion := toc.Version.DocVersion
|
||||||
topVersion := toc.AvailableVersions[0].DocVersion
|
topVersion := toc.AvailableVersions[0].DocVersion
|
||||||
if currentVersion != topVersion {
|
if currentVersion != topVersion {
|
||||||
return NewFormatedError("verifyVersion : retrieved version is not the latest. Found %s, latest is %s", currentVersion, topVersion)
|
return NewFormatedError("verifyVersion: retrieved version is not the latest. Found %s, latest is %s", currentVersion, topVersion)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user