Skip to content

Commit 86af3f5

Browse files
authored
Merge pull request #9 from tj-python/feat/improve-error-handling
feat: Improve error handling
2 parents df5fbfa + b28bbc4 commit 86af3f5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

github_deploy/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ def list_commands(self, ctx):
1717
def get_command(self, ctx, name):
1818
ns = {}
1919
fn = os.path.join(plugin_folder, name + '.py')
20-
with open(fn) as f:
21-
code = compile(f.read(), fn, 'exec')
22-
eval(code, ns, ns)
23-
return ns['main']
20+
21+
if os.path.exists(fn):
22+
with open(fn) as f:
23+
code = compile(f.read(), fn, 'exec')
24+
eval(code, ns, ns)
25+
return ns['main']
26+
27+
ctx.fail("Invalid Command: {name}".format(name=name))
2428

2529

2630
main = GithubDeploy(

0 commit comments

Comments
 (0)