changeset 37:ead830ce45d6 Root_roc_1

better error messages
author casties
date Wed, 12 Apr 2006 20:53:00 +0200
parents 0bf5aac0ff41
children 025d3b6cba51
files documentViewer.py
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Wed Apr 12 19:47:53 2006 +0200
+++ b/documentViewer.py	Wed Apr 12 20:53:00 2006 +0200
@@ -177,13 +177,13 @@
             except:
                 zLOG.LOG("documentViewer (getdirinfofromdigilib)", zLOG.ERROR, "error reading %s (try %d)"%(imageUrl,cnt))
         else:
-            raise IOError("Unable to get dirinfo from %s"%(imageUrl))
+            raise IOError("Unable to get dir-info from %s"%(imageUrl))
         
-        params=dom.xpath("//dir/size")
-        zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%params)
+        sizes=dom.xpath("//dir/size")
+        zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%sizes)
         
-        if params:
-            docinfo['numPages'] = int(getTextFromNode(params[0]))
+        if sizes:
+            docinfo['numPages'] = int(getTextFromNode(sizes[0]))
         else:
             docinfo['numPages'] = 0
                         
@@ -199,7 +199,7 @@
                 dom = NonvalidatingReader.parseUri(url)
             except:
                 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
-                raise IOError("Unable to get info from %s"%(url))
+                raise IOError("Unable to read index.meta from %s"%(url))
         else:
             # online path
             server=self.digilibBaseUrl+"/servlet/Texter?fn="
@@ -210,14 +210,14 @@
                 dom = NonvalidatingReader.parseUri(metaUrl)
             except:
                 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
-                raise IOError("Unable to get info from %s"%(url))
+                raise IOError("Unable to read index meta from %s"%(url))
                  
         return dom
                         
         
     def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None):
         """gets authorization info from the index.meta file at path or given by dom"""
-        zLOG.LOG("documentViewer (getbibinfofromindexmeta)", zLOG.INFO,"path: %s"%(path))
+        zLOG.LOG("documentViewer (getauthinfofromindexmeta)", zLOG.INFO,"path: %s"%(path))
         
         access = None
         
@@ -293,7 +293,8 @@
        if imageDirs and (len(imageDirs)>0):
            imageDir=getTextFromNode(imageDirs[0])
        else:
-           imageDir=None
+           # we balk with no image tag
+           raise IOError("No text-tool info in %s"%(url))
            
        if imageDir and archivePath:
            #print "image: ", imageDir, " archivepath: ", archivePath
@@ -352,6 +353,8 @@
             docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo)
         else:
             zLOG.LOG("documentViewer (getdocinfo)", zLOG.ERROR,"unknown mode!")
+            raise ValueError("Unknown mode %s"%(mode))
+                        
         zLOG.LOG("documentViewer (getdocinfo)", zLOG.INFO,"docinfo: %s"%docinfo)
         self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo