Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Error code registry. #119

Closed
Lukasa opened this issue Apr 11, 2015 · 4 comments
Closed

Error code registry. #119

Lukasa opened this issue Apr 11, 2015 · 4 comments
Labels

Comments

@Lukasa
Copy link
Member

Lukasa commented Apr 11, 2015

Right now if we get an unexpected GOAWAY we print this in the exception hyper.http20.exceptions.ConnectionError: Encountered error 12, extra data b''.. This is fine, but we can do better.

We should bring in the error code registry from the spec so that we can print something more like this: hyper.http20.exceptions.ConnectionError: Error INADEQUATE_SECURITY (0xc): Negotiated TLS parameters not acceptable.

Ideally, the exception itself should be more structured, allowing easy access to numerical error codes, textual error names, long-form error descriptions, and the extra data.

I suspect the format string is roughly going to be "Error {s:name} ({d:errno}): {s:long_error}", where long_error is the extra data if it's available, and the description from the spec if it's not available.

@Lukasa Lukasa added the Easy label Apr 11, 2015
@jdecuyper
Copy link
Contributor

@Lukasa: we could have all the 14 error codes and descriptions loaded in some static array (see spec) and then just use the error code to index into it.

The file could be called error_code.py and be kept under hyper.http20, any comments?

@Lukasa
Copy link
Member Author

Lukasa commented May 1, 2015

Sounds good to me!

@jdecuyper
Copy link
Contributor

@Lukasa hola amigo!

I'm wondering if this is the way I should throw the GoAway error:

if frame.error_code != 0:
   err_name = H2_ERROR_CODE_REGISTRY[frame.error_code]['Name']
   err_no = hex(frame.error_code)
   err_description = frame.additional_data or
   H2_ERROR_CODE_REGISTRY[frame.error_code]['Description']

   raise ConnectionError(
          "Encountered error %s %s: %s" %
          (err_name, err_no, err_description)
   )

Where H2_ERROR_CODE_REGISTRY is the new array containing all the error codes I have just added.

Should we make the error information available via the frame itself or have another exception for this?

I will try to add a new test that consumes a GoAway frame.

@Lukasa
Copy link
Member Author

Lukasa commented May 5, 2015

Thanks works well. I don't think the frame itself should know about error code meanings. What you should do, however, is tolerate error codes outside the registry without exploding. =)

@Lukasa Lukasa closed this as completed May 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants