mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
do not create new error when error is catched
This commit is contained in:
@@ -32,9 +32,8 @@ export function fetchConfig(link: string) {
|
||||
.then(data => {
|
||||
dispatch(fetchConfigSuccess(data));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`could not fetch config: ${cause.message}`);
|
||||
dispatch(fetchConfigFailure(error));
|
||||
.catch(err => {
|
||||
dispatch(fetchConfigFailure(err));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -73,13 +72,8 @@ export function modifyConfig(config: Config, callback?: () => void) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
dispatch(
|
||||
modifyConfigFailure(
|
||||
config,
|
||||
new Error(`could not modify config: ${cause.message}`)
|
||||
)
|
||||
);
|
||||
.catch(err => {
|
||||
dispatch(modifyConfigFailure(config, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,9 +54,8 @@ export function fetchGroupsByLink(link: string) {
|
||||
.then(data => {
|
||||
dispatch(fetchGroupsSuccess(data));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`could not fetch groups: ${cause.message}`);
|
||||
dispatch(fetchGroupsFailure(link, error));
|
||||
.catch(err => {
|
||||
dispatch(fetchGroupsFailure(link, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -105,9 +104,8 @@ function fetchGroup(link: string, name: string) {
|
||||
.then(data => {
|
||||
dispatch(fetchGroupSuccess(data));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`could not fetch group: ${cause.message}`);
|
||||
dispatch(fetchGroupFailure(name, error));
|
||||
.catch(err => {
|
||||
dispatch(fetchGroupFailure(name, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -151,10 +149,10 @@ export function createGroup(link: string, group: Group, callback?: () => void) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
createGroupFailure(
|
||||
new Error(`Failed to create group ${group.name}: ${error.message}`)
|
||||
err
|
||||
)
|
||||
);
|
||||
});
|
||||
@@ -201,11 +199,11 @@ export function modifyGroup(group: Group, callback?: () => void) {
|
||||
.then(() => {
|
||||
dispatch(fetchGroupByLink(group));
|
||||
})
|
||||
.catch(cause => {
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
modifyGroupFailure(
|
||||
group,
|
||||
new Error(`could not modify group ${group.name}: ${cause.message}`)
|
||||
err
|
||||
)
|
||||
);
|
||||
});
|
||||
@@ -259,11 +257,8 @@ export function deleteGroup(group: Group, callback?: () => void) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(
|
||||
`could not delete group ${group.name}: ${cause.message}`
|
||||
);
|
||||
dispatch(deleteGroupFailure(group, error));
|
||||
.catch(err => {
|
||||
dispatch(deleteGroupFailure(group, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -224,9 +224,8 @@ export function modifyRepo(repository: Repository, callback?: () => void) {
|
||||
.then(() => {
|
||||
dispatch(fetchRepoByLink(repository));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`failed to modify repo: ${cause.message}`);
|
||||
dispatch(modifyRepoFailure(repository, error));
|
||||
.catch(err => {
|
||||
dispatch(modifyRepoFailure(repository, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// @flow
|
||||
|
||||
import type {Action} from "@scm-manager/ui-components";
|
||||
import {apiClient} from "@scm-manager/ui-components";
|
||||
import type { Action } from "@scm-manager/ui-components";
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
import * as types from "../../../modules/types";
|
||||
import type {Permission, PermissionCollection, PermissionCreateEntry} from "@scm-manager/ui-types";
|
||||
import {isPending} from "../../../modules/pending";
|
||||
import {getFailure} from "../../../modules/failure";
|
||||
import {Dispatch} from "redux";
|
||||
import type {
|
||||
Permission,
|
||||
PermissionCollection,
|
||||
PermissionCreateEntry
|
||||
} from "@scm-manager/ui-types";
|
||||
import { isPending } from "../../../modules/pending";
|
||||
import { getFailure } from "../../../modules/failure";
|
||||
import { Dispatch } from "redux";
|
||||
|
||||
export const FETCH_PERMISSIONS = "scm/permissions/FETCH_PERMISSIONS";
|
||||
export const FETCH_PERMISSIONS_PENDING = `${FETCH_PERMISSIONS}_${
|
||||
@@ -141,13 +145,8 @@ export function modifyPermission(
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(
|
||||
`failed to modify permission: ${cause.message}`
|
||||
);
|
||||
dispatch(
|
||||
modifyPermissionFailure(permission, error, namespace, repoName)
|
||||
);
|
||||
.catch(err => {
|
||||
dispatch(modifyPermissionFailure(permission, err, namespace, repoName));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -241,15 +240,7 @@ export function createPermission(
|
||||
}
|
||||
})
|
||||
.catch(err =>
|
||||
dispatch(
|
||||
createPermissionFailure(
|
||||
new Error(
|
||||
`failed to add permission ${permission.name}: ${err.message}`
|
||||
),
|
||||
namespace,
|
||||
repoName
|
||||
)
|
||||
)
|
||||
dispatch(createPermissionFailure(err, namespace, repoName))
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -318,13 +309,8 @@ export function deletePermission(
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(
|
||||
`could not delete permission ${permission.name}: ${cause.message}`
|
||||
);
|
||||
dispatch(
|
||||
deletePermissionFailure(permission, namespace, repoName, error)
|
||||
);
|
||||
.catch(err => {
|
||||
dispatch(deletePermissionFailure(permission, namespace, repoName, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ export function fetchSources(
|
||||
dispatch(fetchSourcesSuccess(repository, revision, path, sources));
|
||||
})
|
||||
.catch(err => {
|
||||
const error = new Error(`failed to fetch sources: ${err.message}`);
|
||||
dispatch(fetchSourcesFailure(repository, revision, path, error));
|
||||
dispatch(fetchSourcesFailure(repository, revision, path, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ export const DELETE_USER_FAILURE = `${DELETE_USER}_${types.FAILURE_SUFFIX}`;
|
||||
|
||||
const CONTENT_TYPE_USER = "application/vnd.scmm-user+json;v=2";
|
||||
|
||||
// TODO i18n for error messages
|
||||
|
||||
// fetch users
|
||||
|
||||
export function fetchUsers(link: string) {
|
||||
@@ -57,9 +55,8 @@ export function fetchUsersByLink(link: string) {
|
||||
.then(data => {
|
||||
dispatch(fetchUsersSuccess(data));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`could not fetch users: ${cause.message}`);
|
||||
dispatch(fetchUsersFailure(link, error));
|
||||
.catch(err => {
|
||||
dispatch(fetchUsersFailure(link, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -108,9 +105,8 @@ function fetchUser(link: string, name: string) {
|
||||
.then(data => {
|
||||
dispatch(fetchUserSuccess(data));
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(`could not fetch user: ${cause.message}`);
|
||||
dispatch(fetchUserFailure(name, error));
|
||||
.catch(err => {
|
||||
dispatch(fetchUserFailure(name, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -155,13 +151,7 @@ export function createUser(link: string, user: User, callback?: () => void) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(err =>
|
||||
dispatch(
|
||||
createUserFailure(
|
||||
new Error(`failed to add user ${user.name}: ${err.message}`)
|
||||
)
|
||||
)
|
||||
);
|
||||
.catch(err => dispatch(createUserFailure(err)));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -260,11 +250,8 @@ export function deleteUser(user: User, callback?: () => void) {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
const error = new Error(
|
||||
`could not delete user ${user.name}: ${cause.message}`
|
||||
);
|
||||
dispatch(deleteUserFailure(user, error));
|
||||
.catch(err => {
|
||||
dispatch(deleteUserFailure(user, err));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user