← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~maxiberta/launchpad/sshkeyadditionerror-msg-format into lp:launchpad

 


Diff comments:

> === modified file 'lib/lp/registry/interfaces/ssh.py'
> --- lib/lp/registry/interfaces/ssh.py	2018-02-24 09:11:39 +0000
> +++ lib/lp/registry/interfaces/ssh.py	2018-06-19 21:32:30 +0000
> @@ -124,4 +124,21 @@
>  
>  @error_status(httplib.BAD_REQUEST)
>  class SSHKeyAdditionError(Exception):
> -    """Raised when the SSH public key is invalid."""
> +    """Raised when the SSH public key is invalid.
> +
> +    WARNING: Be careful when changing the message format as
> +    SSO uses a regex to recognize it.
> +    """
> +
> +    def __init__(self, *args, **kwargs):
> +        msg = ""
> +        if 'key' in kwargs:
> +            key = kwargs.pop('key')
> +            msg = "Invalid SSH key data: '%s'" % key
> +        if 'kind' in kwargs:
> +            kind = kwargs.pop('kind')
> +            msg = "Invalid SSH key type: '%s'" % kind
> +        if 'exception' in kwargs:
> +            exception = kwargs.pop('exception')
> +            msg = "%s (%s)" % (msg, str(exception).decode('utf-8', 'ignore'))

That's a lot better. Thanks!

> +        super(SSHKeyAdditionError, self).__init__(msg, *args, **kwargs)


-- 
https://code.launchpad.net/~maxiberta/launchpad/sshkeyadditionerror-msg-format/+merge/348230
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~maxiberta/launchpad/sshkeyadditionerror-msg-format into lp:launchpad.


References