Skip to content

Commit aa717c7

Browse files
authored
Fix/simcore sdk error messages (#2226)
* Fix on simcore_sdk error message to avoid '\n' * Bump simcore-sdk version: 0.3.1 → 0.3.2
1 parent 6394d85 commit aa717c7

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

packages/simcore-sdk/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.1
2+
current_version = 0.3.2
33
commit = True
44
tag = False
55

packages/simcore-sdk/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def read_reqs(reqs_path: Path):
2424

2525
setup(
2626
name="simcore-sdk",
27-
version="0.3.1",
27+
version="0.3.2",
2828
packages=find_packages(where="src"),
2929
package_dir={"": "src"},
3030
python_requires=">=3.6",

packages/simcore-sdk/src/simcore_sdk/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
33
"""
44

5-
__version__ = "0.3.1"
5+
__version__ = "0.3.2"

packages/simcore-sdk/src/simcore_sdk/node_ports/exceptions.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Errors raised by node_ports module as NodeportsException
2+
#
3+
#
4+
# NOTE: Error message SHALL explain the reason for the error and it is prefered in one line, i.e. avoid '\n' in message
5+
#
6+
#
7+
18
from typing import Optional
29

310

@@ -48,7 +55,7 @@ class InvalidProtocolError(NodeportsException):
4855
"""Invalid protocol used"""
4956

5057
def __init__(self, dct, msg: Optional[str] = None):
51-
super().__init__(f"Invalid protocol used: {dct}\n{msg}")
58+
super().__init__(f"Invalid protocol used: {dct} [{msg}]")
5259
self.dct = dct
5360

5461

packages/simcore-sdk/src/simcore_sdk/node_ports/filemanager.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import warnings
66
from contextlib import contextmanager
77
from pathlib import Path
8-
from typing import Optional, Tuple
8+
from typing import Optional, Tuple, Union
99

1010
import aiofiles
1111
from aiohttp import ClientPayloadError, ClientSession, ClientTimeout
@@ -69,14 +69,21 @@ def api_client():
6969
del client
7070

7171

72-
def _handle_api_exception(store_id: str, err: ApiException):
72+
def _handle_api_exception(store_id: Union[int, str], err: ApiException):
73+
""" Maps client's ApiException -> NodeportsException """
74+
75+
# NOTE: ApiException produces a long __str__ with multiple lines which is not
76+
# allowed when composing header
77+
# SEE https://github.com/tornadoweb/tornado/blob/master/tornado/http1connection.py#L456
78+
error_reason: str = err.reason.replace("\n", "-")
79+
7380
if err.status > 399 and err.status < 500:
7481
# something invalid
75-
raise exceptions.StorageInvalidCall(err)
82+
raise exceptions.StorageInvalidCall(error_reason)
7683
if err.status > 499:
7784
# something went bad inside the storage server
78-
raise exceptions.StorageServerIssue(err)
79-
raise exceptions.StorageConnectionError(store_id, err)
85+
raise exceptions.StorageServerIssue(error_reason)
86+
raise exceptions.StorageConnectionError(store_id, error_reason)
8087

8188

8289
async def _get_location_id_from_location_name(store: str, api: UsersApi):

0 commit comments

Comments
 (0)