From 442a1cf96de0fe776ab25bef9e0144ddb7146368 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 10 Apr 2021 15:24:22 +0200 Subject: [PATCH] Return a dict structure to the API for ValidationErrors, for easier error identification/interface --- src/yunohost/utils/error.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/yunohost/utils/error.py b/src/yunohost/utils/error.py index c0ff2690c..f9b4ac61a 100644 --- a/src/yunohost/utils/error.py +++ b/src/yunohost/utils/error.py @@ -48,7 +48,7 @@ class YunohostError(MoulinetteError): def content(self): if not self.log_ref: - return super(YunohostError, self).content() + return super().content() else: return {"error": self.strerror, "log_ref": self.log_ref} @@ -56,3 +56,7 @@ class YunohostError(MoulinetteError): class YunohostValidationError(YunohostError): http_code = 400 + + def content(self): + + return {"error": self.strerror, "error_key": self.key}