Catch first file patch failed exception.

Review Request #3324 — Created Sept. 7, 2012 and submitted

Information

Review Board
master

Reviewers

Catch exception when first file diff fails to apply.
This makes the view diff display the "Diff currently unavailable" error message instead of just throwing out the traceback onto screen.
Tested on local 1.7 beta 3 (dev) server.
Description From Last Updated

Unfortunately, this won't work in Python 2.4. It'll need to be changed to do the work that's in the else: …

chipx86chipx86

We should log any exceptions.

chipx86chipx86
DE
chipx86
  1. 
      
  2. reviewboard/diffviewer/views.py (Diff revision 2)
     
     
     
     
     
     
    Unfortunately, this won't work in Python 2.4. It'll need to be changed to do the work that's in the else: clause without using an else: clause.
    1. Why it won't work in Python 2.4?
      
      Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> try:
      ...   None[0]
      ... except Exception, e:
      ...   print 'Exception'
      ... else:
      ...   print 'No Exception'
      ...
      Exception
      >>> try:
      ...   pass
      ... except Exception, e:
      ...   print 'Exception'
      ... else:
      ...   print 'No Exception'
      ...
      No Exception
    2. Sorry, you're right. I was thinking try/except/finally.
  3. reviewboard/diffviewer/views.py (Diff revision 2)
     
     
     
    We should log any exceptions.
    1. Now the patch provides the diff fragment error preloaded (instead of just skipping the preload part) so the exception is properly enclosed in page (there's no "re-run" of populate diff chunks happening now).
  4. 
      
DE
david
  1. Ship It!
  2. 
      
DE
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (59101b9). Thanks!
MA
  1. Ship It!
  2. 
      
Loading...