Skip to content

Commit 46560e7

Browse files
author
Maurizio Branca
committed
Use more specific errors
1 parent 1887ea2 commit 46560e7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arduino-cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@
99
log = None
1010

1111

12+
class CommandExecutionFailed(Exception):
13+
pass
14+
15+
16+
class CommandNotSupported(Exception):
17+
pass
18+
19+
1220
def run_command(cmd):
1321
from invoke import run
1422

1523
cmd = "./arduino-cli {cmd} --format json".format(cmd=cmd)
1624

1725
result = run(cmd, hide=True, warn=True)
1826
if not result.ok:
19-
raise Exception(result.stdout)
27+
raise CommandExecutionFailed(result.stdout)
2028

2129
return json.loads(result.stdout)
2230

@@ -41,7 +49,7 @@ def run(self):
4149
command = getattr(self, name, None)
4250

4351
if not callable(command):
44-
raise Exception("Command not supported")
52+
raise CommandNotSupported("Command not supported")
4553

4654
command()
4755

0 commit comments

Comments
 (0)