mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
add projectId to error message
This commit is contained in:
parent
9f4727f362
commit
da0fbfefc6
|
@ -37,8 +37,8 @@ class UnlicensedProjectRoleError extends BadRequestError {
|
|||
}
|
||||
|
||||
class ProjectNotFoundError extends NotFoundError {
|
||||
constructor() {
|
||||
super('Project not found.');
|
||||
constructor(projectId: string) {
|
||||
super(`Could not find project with ID: ${projectId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ export class ProjectService {
|
|||
|
||||
const project = await this.getProjectWithScope(user, projectId, ['project:delete']);
|
||||
if (!project || project.type !== 'team') {
|
||||
throw new ProjectNotFoundError();
|
||||
throw new ProjectNotFoundError(projectId);
|
||||
}
|
||||
|
||||
let targetProject: Project | null = null;
|
||||
|
@ -190,7 +190,7 @@ export class ProjectService {
|
|||
{ name, icon },
|
||||
);
|
||||
if (!result.affected) {
|
||||
throw new ProjectNotFoundError();
|
||||
throw new ProjectNotFoundError(projectId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ export class ProjectService {
|
|||
relations: { projectRelations: true },
|
||||
});
|
||||
if (!project) {
|
||||
throw new ProjectNotFoundError();
|
||||
throw new ProjectNotFoundError(projectId);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ export class ProjectService {
|
|||
async deleteUserFromProject(projectId: string, userId: string) {
|
||||
const projectExists = await this.projectRepository.existsBy({ id: projectId });
|
||||
if (!projectExists) {
|
||||
throw new ProjectNotFoundError();
|
||||
throw new ProjectNotFoundError(projectId);
|
||||
}
|
||||
|
||||
// TODO: do we need to prevent project owner from being removed?
|
||||
|
@ -266,7 +266,7 @@ export class ProjectService {
|
|||
async changeUserRoleInProject(projectId: string, userId: string, role: ProjectRole) {
|
||||
const projectUserExists = await this.projectRelationRepository.existsBy({ projectId, userId });
|
||||
if (!projectUserExists) {
|
||||
throw new ProjectNotFoundError();
|
||||
throw new ProjectNotFoundError(projectId);
|
||||
}
|
||||
|
||||
// TODO: do we need to block any specific roles here?
|
||||
|
|
|
@ -492,7 +492,7 @@ describe('Projects in Public API', () => {
|
|||
.send(payload);
|
||||
|
||||
expect(response.status).toBe(404);
|
||||
expect(response.body).toHaveProperty('message', 'Project not found.');
|
||||
expect(response.body).toHaveProperty('message', 'Could not find project with ID: 123456');
|
||||
});
|
||||
|
||||
it('should add expected users to project', async () => {
|
||||
|
@ -647,7 +647,7 @@ describe('Projects in Public API', () => {
|
|||
.send({ role: 'project:editor' })
|
||||
.expect(404);
|
||||
|
||||
expect(response.body).toHaveProperty('message', 'Project not found.');
|
||||
expect(response.body).toHaveProperty('message', 'Could not find project with ID: 123456');
|
||||
});
|
||||
|
||||
it('should reject with 404 if user is not in the project', async () => {
|
||||
|
@ -663,7 +663,10 @@ describe('Projects in Public API', () => {
|
|||
.send({ role: 'project:editor' })
|
||||
.expect(404);
|
||||
|
||||
expect(response.body).toHaveProperty('message', 'Project not found.');
|
||||
expect(response.body).toHaveProperty(
|
||||
'message',
|
||||
`Could not find project with ID: ${project.id}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -752,7 +755,7 @@ describe('Projects in Public API', () => {
|
|||
.delete(`/projects/123456/users/${member.id}`);
|
||||
|
||||
expect(response.status).toBe(404);
|
||||
expect(response.body).toHaveProperty('message', 'Project not found.');
|
||||
expect(response.body).toHaveProperty('message', 'Could not find project with ID: 123456');
|
||||
});
|
||||
|
||||
it('should remain unchanged if user if not in project', async () => {
|
||||
|
|
Loading…
Reference in a new issue