From 25c65547458a3a2f4f4f8b1b70541229f3cbcc0c Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 6 May 2020 12:35:16 -0500 Subject: http api: catch appropriate errors --- src/services/vyos-http-api-server | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index 14cdd8437..4928b0bae 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -229,6 +229,8 @@ def retrieve_op(): return error(400, "\"{0}\" is not a valid operation".format(op)) except VyOSError as e: return error(400, str(e)) + except ConfigSessionError as e: + return error(400, str(e)) except Exception as e: print(traceback.format_exc(), file=sys.stderr) return error(500, "An internal error occured. Check the logs for details.") @@ -264,7 +266,7 @@ def config_file_op(): res = session.commit() else: return error(400, "\"{0}\" is not a valid operation".format(op)) - except VyOSError as e: + except ConfigSessionError as e: return error(400, str(e)) except Exception as e: print(traceback.format_exc(), file=sys.stderr) @@ -300,7 +302,7 @@ def image_op(): res = session.remove_image(name) else: return error(400, "\"{0}\" is not a valid operation".format(op)) - except VyOSError as e: + except ConfigSessionError as e: return error(400, str(e)) except Exception as e: print(traceback.format_exc(), file=sys.stderr) -- cgit v1.2.3