SF.net SVN: gar:[23264] csw/mgar/gar/v2/src

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Mar 21 02:33:30 CET 2014


Revision: 23264
          http://sourceforge.net/p/gar/code/23264
Author:   wahwah
Date:     2014-03-21 01:33:28 +0000 (Fri, 21 Mar 2014)
Log Message:
-----------
cat-gen: Error handling for JSON decode errors

If we can't decode JSON, it's better to die rather than return an empty
catalog with no error.

Modified Paths:
--------------
    csw/mgar/gar/v2/src/Makefile
    csw/mgar/gar/v2/src/catalog-release-to-disk.go

Modified: csw/mgar/gar/v2/src/Makefile
===================================================================
--- csw/mgar/gar/v2/src/Makefile	2014-03-21 00:38:32 UTC (rev 23263)
+++ csw/mgar/gar/v2/src/Makefile	2014-03-21 01:33:28 UTC (rev 23264)
@@ -1,5 +1,10 @@
-all: make-catalog-links
+# To build and push to the web host:
+#
+# 1. gmake
+# 2. scp to the web host to replace the old binary
 
+all: catalog-release-to-disk
+
 catalog-release-to-disk: catalog-release-to-disk.o
 	gccgo -o $@ $<
 

Modified: csw/mgar/gar/v2/src/catalog-release-to-disk.go
===================================================================
--- csw/mgar/gar/v2/src/catalog-release-to-disk.go	2014-03-21 00:38:32 UTC (rev 23263)
+++ csw/mgar/gar/v2/src/catalog-release-to-disk.go	2014-03-21 01:33:28 UTC (rev 23264)
@@ -226,7 +226,10 @@
 
   catspecs := make(CatalogSpecs, 0)
   dec := json.NewDecoder(resp.Body)
-  dec.Decode(&catspecs)
+  if err := dec.Decode(&catspecs); err != nil {
+    log.Println("Failed to decode JSON from", url)
+    return nil, err
+  }
 
   if len(catspecs) <= 0 {
     return nil, fmt.Errorf("Retrieved 0 catalogs")
@@ -249,7 +252,10 @@
 
   var pkgs Catalog
   dec := json.NewDecoder(resp.Body)
-  dec.Decode(&pkgs)
+  if err := dec.Decode(&pkgs); err != nil {
+    log.Println("Failed to decode JSON output from", url, ":", err)
+    return CatalogWithSpec{}, err
+  }
 
   log.Println("Retrieved", catspec, "with", len(pkgs), "packages")
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list