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