mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +01:00
Merge branch 'dev' into 'master'
Release 4.0.0 See merge request turris/reforis/foris-js!91
This commit is contained in:
commit
57bebc92c7
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "3.4.0",
|
"version": "4.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "3.4.0",
|
"version": "4.0.0",
|
||||||
"description": "Set of components and utils for Foris and its plugins.",
|
"description": "Set of components and utils for Foris and its plugins.",
|
||||||
"author": "CZ.NIC, z.s.p.o.",
|
"author": "CZ.NIC, z.s.p.o.",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -53,10 +53,11 @@ function createAPIHook(method) {
|
||||||
payload: result.data,
|
payload: result.data,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorPayload = getErrorPayload(error);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: API_ACTIONS.FAILURE,
|
type: API_ACTIONS.FAILURE,
|
||||||
status: error.response && error.response.status,
|
status: error.response && error.response.status,
|
||||||
payload: getErrorPayload(error),
|
payload: errorPayload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [urlRoot, contentType]);
|
}, [urlRoot, contentType]);
|
||||||
|
@ -80,6 +81,12 @@ function APIReducer(state, action) {
|
||||||
if (action.status === 403) {
|
if (action.status === 403) {
|
||||||
window.location.assign(ForisURLs.login);
|
window.location.assign(ForisURLs.login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not an API error - should be rethrown.
|
||||||
|
if (action.payload && action.payload.stack && action.payload.message) {
|
||||||
|
throw (action.payload);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state: API_STATE.ERROR,
|
state: API_STATE.ERROR,
|
||||||
data: action.payload,
|
data: action.payload,
|
||||||
|
|
|
@ -65,9 +65,8 @@ export function getErrorPayload(error) {
|
||||||
if (error.request) {
|
if (error.request) {
|
||||||
return _("No response received.");
|
return _("No response received.");
|
||||||
}
|
}
|
||||||
/* eslint no-console: "off" */
|
// Return original error because it's not directly related to API request/response.
|
||||||
console.error(error);
|
return error;
|
||||||
return _("An unknown error occurred. Check the console for more info.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJSONErrorMessage(error) {
|
export function getJSONErrorMessage(error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user