diff --git a/src/core/pyros_django/obsconfig/templates/obsconfig/edit_config.html b/src/core/pyros_django/obsconfig/templates/obsconfig/edit_config.html index 9713796..9464468 100644 --- a/src/core/pyros_django/obsconfig/templates/obsconfig/edit_config.html +++ b/src/core/pyros_django/obsconfig/templates/obsconfig/edit_config.html @@ -26,6 +26,11 @@ left:80vw; top: 30vh; } + #message{ + position:absolute; + left:80vw; + top: 25vh; + } .red{ color:red; @@ -46,8 +51,8 @@ -
"+message+"
"); + if (data["message"]){ + for(error of data["message"] ){ + for(message of error){ + $("#message").append(""+message+"
"); - } + } + } + } + console.log(data["yaml_error_message"]) + if (data["yaml_error_message"]){ + console.log("yaml_error_message") + let message = data["yaml_error_message"]; + $("#message").append(""+message+""); } } }); diff --git a/src/core/pyros_django/obsconfig/views.py b/src/core/pyros_django/obsconfig/views.py index d18bc34..541230e 100644 --- a/src/core/pyros_django/obsconfig/views.py +++ b/src/core/pyros_django/obsconfig/views.py @@ -243,7 +243,18 @@ def verify_config(request): temp_config_file.write(request.POST.get("config")) temp_config_file.seek(0) response_data = {} - config_file = yaml.safe_load(temp_config_file.read()) + try: + config_file = yaml.safe_load(temp_config_file.read()) + except yaml.YAMLError as exc: + if hasattr(exc, 'problem_mark'): + yaml_error_message = "" + if exc.context != None: + yaml_error_message += str(exc.problem_mark) + '\n ' + str(exc.problem) + ' ' + str(exc.context) + else: + yaml_error_message = str(exc.problem_mark.name) + '\n ' +str(exc.problem) + response_data["is_valid"] = False + response_data["yaml_error_message"] = yaml_error_message + return HttpResponse(json.dumps(response_data), content_type="application/json") temp_config_file.seek(0) schema = config_file["schema"] errors = [] -- libgit2 0.21.2