Attachment 'whaterr.py'
Download 1 #!/usr/bin/python
2 """
3 Renders couchdb / erlang errors nicely. Receives the error on stdin and sends to stdout
4 """
5
6 import sys
7 from urllib import urlopen
8 import json
9
10 if len(sys.argv) == 2:
11 try:
12 data = urlopen(sys.argv[1]).read()
13 except:
14 print "Couldn't download url:", sys.argv[1]
15 exit()
16 try:
17 data = json.loads(data)
18 except:
19 print "Response wasn't valid json. RESPONSE:"
20 print data
21 exit()
22 print 'ERROR:', data['error']
23 print
24 print 'REASON:'
25 print data['reason']
26 else:
27 print '''
28 Usage: %(name)s url
29
30 If you have a url that's printing you a horrble painful error message, (especially mustache errors),
31 this util prints it in a slightly less painful way.
32
33 eg. %(name)s http://localhost:5984/dbname/_design/designname/_list/listname/viewname
34 eg. %(name)s http://localhost:5984/footprint/_design/footprint/_list/products/products
35 ''' % {'name': sys.argv[0]}
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.