fix(#26): gracefully quit on auth failures in hstorm #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things to gracefully exit on auth failures in
hstorm
:HttpCortex.login
method. It moves the originallogin
functionality to a new method,_login
, which the newlogin
method calls. It also adds an optionalclose
argument to the newlogin
method, that defaults toFalse
. WhenTrue
,HttpCortex.stop
is called when_login
raises an exception, thenlogin
reraises that exception. This new argument is set toTrue
in theHttpCortex.__aenter__
method'slogin
call.hstorm.main
around theHttpCortex
call and catchesHttpCortexLoginError
errors. This way only the error message is printed upon a login error.