mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
try to format the error just before ApiError creation
This commit is contained in:
parent
3f3fd2585f
commit
40ef5b2d7e
2 changed files with 3 additions and 3 deletions
|
@ -7,8 +7,8 @@ import i18n from '@/i18n'
|
|||
|
||||
|
||||
class APIError extends Error {
|
||||
constructor (request, { url, status, statusText }, errorData) {
|
||||
super(errorData.error || i18n.t('error_server_unexpected'))
|
||||
constructor (request, { url, status, statusText }, { error }) {
|
||||
super(error ? error.replace('\n', '<br>') : i18n.t('error_server_unexpected'))
|
||||
const urlObj = new URL(url)
|
||||
this.name = 'APIError'
|
||||
this.code = status
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function handleError (request, response, errorData) {
|
|||
let errorCode = response.status in errors ? response.status : undefined
|
||||
if (typeof errorData === 'string') {
|
||||
// FIXME API: Patching errors that are plain text or html.
|
||||
errorData = { error: errorData.replace('\n', '<br>') }
|
||||
errorData = { error: errorData }
|
||||
}
|
||||
if ('log_ref' in errorData) {
|
||||
// Define a special error so it won't get caught as a `APIBadRequestError`.
|
||||
|
|
Loading…
Add table
Reference in a new issue