mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
390ae79ab3
commit
7adf209ff4
7 changed files with 7 additions and 11 deletions
|
@ -98,7 +98,7 @@ function callAPI(client, endpoint, clientParams = {}, options = {}) {
|
|||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
const boomError = Boom.wrap(err, err.statusCode);
|
||||
const boomError = Boom.boomify(err, { statusCode: err.statusCode });
|
||||
const wwwAuthHeader = get(err, 'body.error.header[WWW-Authenticate]');
|
||||
boomError.output.headers['WWW-Authenticate'] = wwwAuthHeader || 'Basic realm="Authorization Required"';
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export function exportApi(server) {
|
|||
.header('Content-Type', 'application/json')
|
||||
.header('Content-Length', json.length);
|
||||
})
|
||||
.catch(err => reply(Boom.wrap(err, 400)));
|
||||
.catch(err => reply(Boom.boomify(err, { statusCode: 400 })));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export function importApi(server) {
|
|||
handler: (req, reply) => {
|
||||
return importDashboards(req)
|
||||
.then((resp) => reply(resp))
|
||||
.catch(err => reply(Boom.wrap(err, 400)));
|
||||
.catch(err => reply(Boom.boomify(err, { statusCode: 400 })));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export default (server) => {
|
|||
.then(reply)
|
||||
.catch(err => {
|
||||
if (err.isBoom && err.status === 401) return reply(err);
|
||||
reply(Boom.wrap(err, 500));
|
||||
reply(Boom.boomify(err, { statusCode: 500 }));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -47,11 +47,7 @@ export function convertEsError(indices, error) {
|
|||
return createNoMatchingIndicesError(indices);
|
||||
}
|
||||
|
||||
if (error.isBoom) {
|
||||
return error;
|
||||
}
|
||||
|
||||
const statusCode = error.statusCode;
|
||||
const message = error.body ? error.body.error : undefined;
|
||||
return Boom.wrap(error, statusCode, message);
|
||||
return Boom.boomify(error, { statusCode, message });
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export default async (kbnServer, server, config) => {
|
|||
await reply.renderStatusPage();
|
||||
}
|
||||
} catch (err) {
|
||||
reply(Boom.wrap(err));
|
||||
reply(Boom.boomify(err));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -111,7 +111,7 @@ export default function ({ getService }) {
|
|||
it('handles errors that are already Boom errors', () => {
|
||||
const error = new Error();
|
||||
error.statusCode = 401;
|
||||
const boomError = Boom.wrap(error, error.statusCode);
|
||||
const boomError = Boom.boomify(error, { statusCode: error.statusCode });
|
||||
|
||||
const converted = convertEsError(indices, boomError);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue