Changeset 1110

Show
Ignore:
Timestamp:
06/29/08 16:43:58 (2 months ago)
Author:
kris
Message:

cleaned up the try/catch in file handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/net/servlet/ServletResponse.d

    r1107 r1110  
    230230                    file = new FileConduit; 
    231231 
    232                 try { 
     232                scope (failure) 
     233                      { 
     234                      sendError (HttpResponses.NotFound); 
     235                      return false; 
     236                      } 
     237 
     238                auto log = (cast(ServletContext) context).log; 
    233239                    if (cache) 
    234240                        if (cache.get (path, info)) 
     
    241247                    char[512] tmp = void; 
    242248                    file.open (context.getResourceAsPath (path, tmp)); 
     249                    scope (exit) 
     250                           file.detach; 
    243251 
    244252                    auto p = Path.parse (path); 
     
    253261                       buffer.copy (file); 
    254262                    return true; 
    255  
    256                     } catch (IOException x) 
    257                             { 
    258                             sendError (HttpResponses.NotFound); 
    259                             } 
    260                       finally  
    261                             { 
    262                             file.detach; 
    263                             } 
    264263                return false; 
    265264        }