Skip to content
Snippets Groups Projects
Commit e99b739f authored by Krzysztof Mochocki's avatar Krzysztof Mochocki
Browse files

Bunch of fixes in detectable errors

parent 6dbc4480
No related branches found
No related tags found
No related merge requests found
...@@ -106,9 +106,9 @@ class UnlockedWallet(Wallet, UnlockedWalletInterface): ...@@ -106,9 +106,9 @@ class UnlockedWallet(Wallet, UnlockedWalletInterface):
@wallet_unlocked @wallet_unlocked
async def remove_key(self, *, key: str) -> None: async def remove_key(self, *, key: str) -> None:
validate_public_keys(key=key) validate_public_keys(key=key)
with NotExistingKeyError(public_key=key), MissingSTMPrefixError(public_key=key), InvalidPublicKeyError( with NotExistingKeyError(public_key=key, wallet_name=self.name), MissingSTMPrefixError(
public_keys=key public_key=key
): ), InvalidPublicKeyError(public_keys=key):
await self._beekeeper.api.remove_key(wallet_name=self.name, public_key=key, token=self.session_token) await self._beekeeper.api.remove_key(wallet_name=self.name, public_key=key, token=self.session_token)
@wallet_unlocked @wallet_unlocked
......
...@@ -97,9 +97,9 @@ class UnlockedWallet(UnlockedWalletInterface, Wallet): ...@@ -97,9 +97,9 @@ class UnlockedWallet(UnlockedWalletInterface, Wallet):
@wallet_unlocked @wallet_unlocked
def remove_key(self, *, key: str) -> None: def remove_key(self, *, key: str) -> None:
validate_public_keys(key=key) validate_public_keys(key=key)
with NotExistingKeyError(public_key=key), MissingSTMPrefixError(public_key=key), InvalidPublicKeyError( with NotExistingKeyError(public_key=key, wallet_name=self.name), MissingSTMPrefixError(
public_keys=key public_key=key
): ), InvalidPublicKeyError(public_keys=key):
self._beekeeper.api.remove_key(wallet_name=self.name, public_key=key, token=self.session_token) self._beekeeper.api.remove_key(wallet_name=self.name, public_key=key, token=self.session_token)
@wallet_unlocked @wallet_unlocked
......
from __future__ import annotations from __future__ import annotations
import re
from beekeepy.exceptions.base import DetectableError, SchemaDetectableError from beekeepy.exceptions.base import DetectableError, SchemaDetectableError
from helpy import exceptions as helpy_errors from helpy import exceptions as helpy_errors
...@@ -35,7 +37,10 @@ class WalletWithSuchNameAlreadyExistsError(DetectableError): ...@@ -35,7 +37,10 @@ class WalletWithSuchNameAlreadyExistsError(DetectableError):
def _is_exception_handled(self, ex: BaseException) -> bool: def _is_exception_handled(self, ex: BaseException) -> bool:
return ( return (
isinstance(ex, helpy_errors.ErrorInResponseError) isinstance(ex, helpy_errors.ErrorInResponseError)
and f"Assert Exception:!bfs::exists(wallet_filename): Wallet with name: '{self.wallet_name}' already exists" and (
"Assert Exception:!fc::exists( wallet_file_name ): "
f"Wallet with name: '{self.wallet_name}' already exists at "
)
in ex.error in ex.error
) )
...@@ -72,11 +77,15 @@ class NotExistingKeyError(DetectableError): ...@@ -72,11 +77,15 @@ class NotExistingKeyError(DetectableError):
super().__init__(f"cannot use key that does not exist: `{public_key}`") super().__init__(f"cannot use key that does not exist: `{public_key}`")
def _is_exception_handled(self, ex: BaseException) -> bool: def _is_exception_handled(self, ex: BaseException) -> bool:
alternative_wallet_search = r"[\w\-\.]+"
return isinstance(ex, helpy_errors.ErrorInResponseError) and any( return isinstance(ex, helpy_errors.ErrorInResponseError) and any(
error_message in ex.error re.search(error_message, ex.error) is not None
for error_message in [ for error_message in [
"Assert Exception:false: Key not in wallet", "Assert Exception:false: Key not in wallet",
f"Assert Exception:false: Public key {self.public_key} not found in {self.wallet_name} wallet", (
f"Assert Exception:false: Public key {self.public_key} not "
f"found in {self.wallet_name or alternative_wallet_search} wallet"
),
] ]
) )
...@@ -138,9 +147,12 @@ class InvalidWalletError(DetectableError): ...@@ -138,9 +147,12 @@ class InvalidWalletError(DetectableError):
return isinstance(ex, helpy_errors.ErrorInResponseError) and any( return isinstance(ex, helpy_errors.ErrorInResponseError) and any(
error_message in ex.error error_message in ex.error
for error_message in [ for error_message in [
"Name of wallet is incorrect. Is empty." "Name of wallet is incorrect. Is empty.",
f"Name of wallet is incorrect. Name: {self.wallet_name}. Only alphanumeric and '._-@' chars are allowed" (
f"Name of wallet is incorrect. Name: {self.wallet_name}. File creation with given name is impossible." f"Name of wallet is incorrect. Name: {self.wallet_name}. "
"Only alphanumeric and '._-@' chars are allowed"
),
f"Name of wallet is incorrect. Name: {self.wallet_name}. File creation with given name is impossible.",
] ]
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment