mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Canvas] Fixes error handling of NetworkErrors (#28282)
* Fixes error handling with NetworkErrors * Removed lodash get
This commit is contained in:
parent
b57461117d
commit
baa7ac2c70
3 changed files with 23 additions and 23 deletions
|
@ -33,7 +33,7 @@ export const routes = [
|
|||
notify.error(err, { title: `Couldn't create workpad` });
|
||||
// TODO: remove this and switch to checking user privileges when canvas loads when granular app privileges are introduced
|
||||
// https://github.com/elastic/kibana/issues/20277
|
||||
if (err.response.status === 403) {
|
||||
if (err.response && err.response.status === 403) {
|
||||
dispatch(setCanUserWrite(false));
|
||||
}
|
||||
router.redirectTo('home');
|
||||
|
@ -61,7 +61,7 @@ export const routes = [
|
|||
// TODO: remove this and switch to checking user privileges when canvas loads when granular app privileges are introduced
|
||||
// https://github.com/elastic/kibana/issues/20277
|
||||
workpadService.update(params.id, fetchedWorkpad).catch(err => {
|
||||
if (err.response.status === 403) {
|
||||
if (err.response && err.response.status === 403) {
|
||||
dispatch(setCanUserWrite(false));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ export const WorkpadLoader = compose(
|
|||
notify.error(err, { title: `Couldn't upload workpad` });
|
||||
// TODO: remove this and switch to checking user privileges when canvas loads when granular app privileges are introduced
|
||||
// https://github.com/elastic/kibana/issues/20277
|
||||
if (err.response.status === 403) {
|
||||
if (err.response && err.response.status === 403) {
|
||||
props.setCanUserWrite(false);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ export const WorkpadLoader = compose(
|
|||
notify.error(err, { title: `Couldn't clone workpad` });
|
||||
// TODO: remove this and switch to checking user privileges when canvas loads when granular app privileges are introduced
|
||||
// https://github.com/elastic/kibana/issues/20277
|
||||
if (err.response.status === 403) {
|
||||
if (err.response && err.response.status === 403) {
|
||||
props.setCanUserWrite(false);
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ export const WorkpadLoader = compose(
|
|||
errors.push(result.id);
|
||||
// TODO: remove this and switch to checking user privileges when canvas loads when granular app privileges are introduced
|
||||
// https://github.com/elastic/kibana/issues/20277
|
||||
if (result.err.response.status === 403) {
|
||||
if (result.err.response && result.err.response.status === 403) {
|
||||
props.setCanUserWrite(false);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -55,26 +55,26 @@ export const esPersistMiddleware = ({ getState }) => {
|
|||
if (workpadChanged(curState, newState) || assetsChanged(curState, newState)) {
|
||||
const persistedWorkpad = getWorkpadPersisted(getState());
|
||||
return update(persistedWorkpad.id, persistedWorkpad).catch(err => {
|
||||
if (err.response.status === 400) {
|
||||
return notify.error(err.response, {
|
||||
title: `Couldn't save your changes to Elasticsearch`,
|
||||
});
|
||||
}
|
||||
|
||||
if (err.response.status === 413) {
|
||||
return notify.error(
|
||||
`The server gave a response that the workpad data was too large. This
|
||||
usually means uploaded image assets that are too large for Kibana or
|
||||
a proxy. Try removing some assets in the asset manager.`,
|
||||
{
|
||||
const statusCode = err.response && err.response.status;
|
||||
switch (statusCode) {
|
||||
case 400:
|
||||
return notify.error(err.response, {
|
||||
title: `Couldn't save your changes to Elasticsearch`,
|
||||
}
|
||||
);
|
||||
});
|
||||
case 413:
|
||||
return notify.error(
|
||||
`The server gave a response that the workpad data was too large. This
|
||||
usually means uploaded image assets that are too large for Kibana or
|
||||
a proxy. Try removing some assets in the asset manager.`,
|
||||
{
|
||||
title: `Couldn't save your changes to Elasticsearch`,
|
||||
}
|
||||
);
|
||||
default:
|
||||
return notify.error(err, {
|
||||
title: `Couldn't update workpad`,
|
||||
});
|
||||
}
|
||||
|
||||
return notify.error(err.response, {
|
||||
title: `Couldn't update workpad`,
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue