8000 Fix how MissingTargetException is raised (#87) · sesi/functions-framework-python@ba6a869 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba6a869

Browse files
authored
Fix how MissingTargetException is raised (GoogleCloudPlatform#87)
1 parent 46d2149 commit ba6a869

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/functions_framework/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,13 @@ def handle_none(rv):
247247
app.make_response = handle_none
248248

249249
# Extract the target function from the source file
250-
try:
251-
function = getattr(source_module, target)
252-
except AttributeError:
250+
if not hasattr(source_module, target):
253251
raise MissingTargetException(
254252
"File {source} is expected to contain a function named {target}".format(
255253
source=source, target=target
256254
)
257255
)
256+
function = getattr(source_module, target)
258257

259258
# Check that it is a function
260259
if not isinstance(function, types.FunctionType):

0 commit comments

Comments
 (0)
0