Mercurial > hg > cc > cirrus_home
changeset 129:b51d65ed6c89
improve error handling
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Fri, 09 Jul 2021 13:45:43 +0000 |
parents | ababa631a10f |
children | 5efc3985d513 |
files | bin/ix.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/ix.py Fri Jul 09 13:45:04 2021 +0000 +++ b/bin/ix.py Fri Jul 09 13:45:43 2021 +0000 @@ -68,7 +68,8 @@ nb=file.readinto(bv) file.close() if nb!=length: - print("losing",file.name,length,nb,file=sys.stderr) + raise ValueError("Chunk read losing: %s, got %s expected %s at %s"%(file.name, + nb,length,offset)) if whole and options.zipped: _output(bv) return @@ -206,11 +207,16 @@ if m is None: if l.find('/robotstxt/')>-1: continue - print("index line problem: \"%s\""%l.lstrip(),file=sys.stderr) + print("index line problem: \"%s\""%l,file=sys.stderr,end='') exit(2) f=FPAT%(m[3:7]) - process(pa,buf,f, - int(m[2]),int(m[1]),whole) + try: + process(pa,buf,f, + int(m[2]),int(m[1]),whole) + except Exception as e: + print("Process fail: %s, input line:\n %s"%(e,l), + file=sys.stderr,end='') + exit(3) elif pa.length is not None: print(pa.filename,file=sys.stderr) process(pa,buf,FPAT%tuple(pa.filename.split('/')),