mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 02:20:49 +01:00
fix: closes #14041, show specific error message
if config fails to save
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"invalid-data": "Invalid Data",
|
||||
"invalid-config-field-value": "Invalid value for config field \"%1\": %2",
|
||||
"invalid-json": "Invalid JSON",
|
||||
"wrong-parameter-type": "A value of type %3 was expected for property `%1`, but %2 was received instead",
|
||||
"required-parameters-missing": "Required parameters were missing from this API call: %1",
|
||||
|
||||
@@ -104,7 +104,7 @@ define('admin/settings', [
|
||||
if (err) {
|
||||
return alerts.alert({
|
||||
alert_id: 'config_status',
|
||||
timeout: 2500,
|
||||
timeout: 5000,
|
||||
title: '[[admin/admin:changes-not-saved]]',
|
||||
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
||||
type: 'danger',
|
||||
|
||||
@@ -544,7 +544,7 @@ define('settings', ['hooks', 'alerts'], function (hooks, alerts) {
|
||||
title: '[[admin/admin:changes-not-saved]]',
|
||||
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
||||
type: 'error',
|
||||
timeout: 2500,
|
||||
timeout: 5000,
|
||||
});
|
||||
} else {
|
||||
const saveBtn = document.getElementById('save');
|
||||
|
||||
@@ -8,6 +8,7 @@ const winston = require('winston');
|
||||
const db = require('../database');
|
||||
const pubsub = require('../pubsub');
|
||||
const Meta = require('./index');
|
||||
const translator = require('../translator');
|
||||
const cacheBuster = require('./cacheBuster');
|
||||
const defaults = require('../../install/data/defaults.json');
|
||||
|
||||
@@ -190,7 +191,9 @@ function ensureInteger(data, field, min) {
|
||||
if (data.hasOwnProperty(field)) {
|
||||
data[field] = parseInt(data[field], 10);
|
||||
if (!(data[field] >= min)) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
throw new Error(translator.compile(
|
||||
'error:invalid-config-field-value', field, data[field]
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user