Ignore:
Timestamp:
Dec 20, 2011, 3:24:01 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
5e44432
Parents:
59a1d4a
git-author:
Jessica B. Hamrick <jhamrick@…> (12/20/11 15:24:01)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/20/11 15:24:01)
Message:

Move ipp error handling out of the server and into server/requests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/server/server.py

    ref8df33 raef164a  
    33import gutenbach.ipp as ipp
    44import logging
     5import sys
    56import traceback
    6 import sys
    77
    88# initialize logger
     
    2727        length = int(self.headers.getheader('content-length', 0))
    2828        request = ipp.Request(request=self.rfile, length=length)
    29         logger.debug("Received request: %s" % repr(request))
    3029
    3130        # Get the handler and pass it the request and response
    3231        # objects.  It will fill in values for the response object or
    33         # thrown an error.
     32        # throw a fatal error.
     33        logger.debug("Received request: %s" % repr(request))
    3434        try:
    3535            response = self.root.handle(request)
    36            
    37         # Handle any errors that occur.  If an exception occurs that
    38         # is an IPP error, then we can get the error code from the
    39         # exception itself.
    40         except ipp.errors.IPPException:
    41             exctype, excval, exctb = sys.exc_info()
    42             logger.error(traceback.format_exc())
    43             response = ipp.ops.make_empty_response(request)
    44             excval.update_response(response)
    45 
    46         # If it wasn't an IPP error, then it's our fault, so mark it
    47         # as an internal server error
    48         except Exception:
    49             logger.error(traceback.format_exc())
    50             response = ipp.ops.make_empty_response(request)
    51             response.operation_id = ipp.StatusCodes.INTERNAL_ERROR
     36        except:
     37            logger.fatal(traceback.format_exc())
     38            sys.exit(1)
    5239
    5340        # Send the response across HTTP
Note: See TracChangeset for help on using the changeset viewer.