forked from tanner/qotnews
feat: Display detailed submission errors to user
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -131,7 +131,7 @@ def submit():
|
|||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
logging.error('Problem with article submission: {} - {}'.format(e.__class__.__name__, str(e)))
|
logging.error('Problem with article submission: {} - {}'.format(e.__class__.__name__, str(e)))
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
abort(400)
|
return {'error': str(e)}, 400
|
||||||
|
|
||||||
|
|
||||||
@flask_app.route('/api/<sid>')
|
@flask_app.route('/api/<sid>')
|
||||||
|
|||||||
@@ -17,13 +17,17 @@ function Submit() {
|
|||||||
data.append('url', url);
|
data.append('url', url);
|
||||||
|
|
||||||
fetch('/api/submit', { method: 'POST', body: data })
|
fetch('/api/submit', { method: 'POST', body: data })
|
||||||
.then(res => res.json())
|
.then(res => res.json().then(data => ({ ok: res.ok, data })))
|
||||||
.then(
|
.then(
|
||||||
(result) => {
|
({ ok, data }) => {
|
||||||
history.replace('/' + result.nid);
|
if (ok) {
|
||||||
|
history.replace('/' + data.nid);
|
||||||
|
} else {
|
||||||
|
setProgress(data.error || 'An unknown error occurred.');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
setProgress('Error');
|
setProgress(`Error: ${error.toString()}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user