Skip to content

Commit f42d841

Browse files
committed
cli: add hql error codes
1 parent 27bea9e commit f42d841

File tree

1 file changed

+9
-4
lines changed
  • components/tools/OmeroPy/src/omero/plugins

1 file changed

+9
-4
lines changed

components/tools/OmeroPy/src/omero/plugins/hql.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ def _configure(self, parser):
4343
parser.add_limit_arguments()
4444
parser.add_style_argument()
4545
parser.add_login_arguments()
46+
self.add_error("NO_QUIET", 67,
47+
"Can't ask for query with --quiet option")
48+
self.add_error("NOT_ADMIN", 53,
49+
("SecurityViolation: Current user is not an"
50+
" admin and cannot use '--admin'"))
51+
self.add_error("BAD_QUERY", 52, "Bad query: %s")
4652

4753
def __call__(self, args):
4854
if args.query:
4955
self.hql(args)
5056
else:
5157
if self.ctx.isquiet:
52-
self.ctx.die(67, "Can't ask for query with --quiet option")
58+
self.raise_error("NO_QUIET")
5359
while True:
5460
args.query = self.ctx.input("Enter query:")
5561
if not args.query:
@@ -246,13 +252,12 @@ def project(self, querySvc, queryStr, params, ice_map):
246252
return rv
247253
except omero.SecurityViolation, sv:
248254
if "omero.group" in ice_map:
249-
self.ctx.die(53, "SecurityViolation: Current user is not an"
250-
" admin and cannot use '--admin'")
255+
self.raise_error("NOT_ADMIN")
251256
else:
252257
self.ctx.die(54, "SecurityViolation: %s" % sv)
253258
except omero.QueryException, qe:
254259
self.ctx.set("last.hql.rv", [])
255-
self.ctx.die(52, "Bad query: %s" % qe.message)
260+
self.raise_error("BAD_QUERY", qe.message)
256261

257262
try:
258263
register("hql", HqlControl, HELP)

0 commit comments

Comments
 (0)