DRY up http error handling

Also fix start time measuring of the main http handler