From b5e90197263bd59b62cf24c631cc4973c4514dd9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 23 Jan 2023 16:45:06 +0000 Subject: op mode: T4951: add InsufficientResources error --- python/vyos/opmode.py | 13 ++++++++++++- src/services/api/graphql/session/errors/op_mode_errors.py | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index 30e893d74..c48866ed8 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -1,4 +1,4 @@ -# Copyright 2022 VyOS maintainers and contributors +# Copyright 2022-2023 VyOS maintainers and contributors # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,10 @@ from humps import decamelize class Error(Exception): """ Any error that makes requested operation impossible to complete for reasons unrelated to the user input or script logic. + + This is the base class, scripts should not use it directly + and should raise more specific errors instead, + whenever possible. """ pass @@ -45,6 +49,13 @@ class PermissionDenied(Error): """ pass +class InsufficientResources(Error): + """ Requested operation and its arguments are valid but the system + does not have enough resources (such as drive space or memory) + to complete it. + """ + pass + class UnsupportedOperation(Error): """ Requested operation is technically valid but is not implemented yet. """ pass diff --git a/src/services/api/graphql/session/errors/op_mode_errors.py b/src/services/api/graphql/session/errors/op_mode_errors.py index 4029fd0a1..a8a9ee426 100644 --- a/src/services/api/graphql/session/errors/op_mode_errors.py +++ b/src/services/api/graphql/session/errors/op_mode_errors.py @@ -4,6 +4,7 @@ op_mode_err_msg = { "UnconfiguredSubsystem": "subsystem is not configured or not running", "DataUnavailable": "data currently unavailable", "PermissionDenied": "client does not have permission", + "InsufficientResources": "insufficient system resources" "IncorrectValue": "argument value is incorrect", "UnsupportedOperation": "operation is not supported (yet)", } @@ -11,6 +12,7 @@ op_mode_err_msg = { op_mode_err_code = { "UnconfiguredSubsystem": 2000, "DataUnavailable": 2001, + "InsufficientResources": 2002, "PermissionDenied": 1003, "IncorrectValue": 1002, "UnsupportedOperation": 1004, -- cgit v1.2.3