Codebase list dnsviz / 03b2bbb
Make error messages more generic Casey Deccio 8 years ago
1 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
520520
521521 # if there is no content, raise an exception
522522 if self.res is None:
523 raise RemoteQueryTransportError('No content in HTTP response')
523 raise RemoteQueryTransportError('No content in response')
524524
525525 # load the json content
526526 try:
527527 content = json.loads(self.res)
528528 except ValueError:
529 raise RemoteQueryTransportError('JSON decoding of HTTP response failed: %s' % self.res)
529 raise RemoteQueryTransportError('JSON decoding of response failed: %s' % self.res)
530530
531531 if 'version' not in content:
532 raise RemoteQueryTransportError('No version information in HTTP response.')
532 raise RemoteQueryTransportError('No version information in response.')
533533 try:
534534 major_vers, minor_vers = map(int, str(content['version']).split('.', 1))
535535 except ValueError:
536 raise RemoteQueryTransportError('Version of JSON input in HTTP response is invalid: %s' % content['version'])
536 raise RemoteQueryTransportError('Version of JSON input in response is invalid: %s' % content['version'])
537537
538538 # ensure major version is a match and minor version is no greater
539539 # than the current minor version
540540 curr_major_vers, curr_minor_vers = map(int, str(DNS_TRANSPORT_VERSION).split('.', 1))
541541 if major_vers != curr_major_vers or minor_vers > curr_minor_vers:
542 raise RemoteQueryTransportError('Version %d.%d of JSON input in HTTP response is incompatible with this software.' % (major_vers, minor_vers))
542 raise RemoteQueryTransportError('Version %d.%d of JSON input in response is incompatible with this software.' % (major_vers, minor_vers))
543543
544544 if 'responses' not in content:
545 raise RemoteQueryTransportError('No response information in HTTP response.')
545 raise RemoteQueryTransportError('No DNS response information in response.')
546546
547547 for i in range(len(self.qtms)):
548548 try:
549549 self.qtms[i].deserialize_response(content['responses'][i])
550550 except IndexError:
551 raise RemoteQueryTransportError('Response information missing from HTTP response')
551 raise RemoteQueryTransportError('DNS response information missing from response')
552552 except TransportMetaDeserializationError, e:
553553 raise RemoteQueryTransportError(str(e))
554554