Skip to content

Commit 0052b8e

Browse files
authored
better import error (#59)
1 parent a719bc0 commit 0052b8e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

polyapi/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"""
1111

1212

13-
def _wrap_code_in_try_except(code: str) -> str:
13+
def _wrap_code_in_try_except(function_name: str, code: str) -> str:
1414
""" this is necessary because client functions with imports will blow up ALL server functions,
1515
even if they don't use them.
1616
because the server function will try to load all client functions when loading the library
1717
"""
1818
prefix = """logger = logging.getLogger("poly")
1919
try:
2020
"""
21-
suffix = """except ImportError as e:
22-
logger.debug(e)"""
21+
suffix = f"""except ImportError as e:
22+
logger.warning("Failed to import client function '{function_name}', function unavailable: " + str(e))"""
2323

2424
lines = code.split("\n")
2525
code = "\n ".join(lines)
@@ -39,6 +39,6 @@ def render_client_function(
3939
return_type_def=return_type_def,
4040
)
4141

42-
code = _wrap_code_in_try_except(code)
42+
code = _wrap_code_in_try_except(function_name, code)
4343

4444
return code + "\n\n", func_type_defs

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
33

44
[project]
55
name = "polyapi-python"
6-
version = "0.3.8.dev4"
6+
version = "0.3.8.dev5"
77
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
88
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
99
dependencies = [

0 commit comments

Comments
 (0)