Skip to content

Commit ae7ceed

Browse files
committed
Remove wrapped exceptions in user repo that are no longer necessary
1 parent 4bb9d54 commit ae7ceed

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

src/components/user/user.edgedb.repository.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { Injectable } from '@nestjs/common';
2-
import {
3-
DuplicateException,
4-
ID,
5-
NotFoundException,
6-
ServerException,
7-
Session,
8-
} from '~/common';
9-
import { e, EdgeDB, isExclusivityViolation } from '~/core/edgedb';
2+
import { ID, NotFoundException, Session } from '~/common';
3+
import { e, EdgeDB } from '~/core/edgedb';
104
import { CreatePerson, User, UserListInput } from './dto';
115
import { UserRepository } from './user.repository';
126

@@ -83,29 +77,14 @@ export class UserEdgedbRepository extends UserRepository {
8377

8478
async create(input: CreatePerson) {
8579
const query = e.insert(e.User, { ...input });
86-
try {
87-
const result = await this.edgedb.run(query);
88-
return result.id;
89-
} catch (e) {
90-
if (isExclusivityViolation(e, 'email')) {
91-
throw new DuplicateException(
92-
'person.email',
93-
'Email address is already in use',
94-
e,
95-
);
96-
}
97-
throw new ServerException('Failed to create user', e);
98-
}
80+
const result = await this.edgedb.run(query);
81+
return result.id;
9982
}
10083

10184
async delete(id: ID, _session: Session, _object: User): Promise<void> {
10285
const query = e.delete(e.User, () => ({
10386
filter_single: { id },
10487
}));
105-
try {
106-
await this.edgedb.run(query);
107-
} catch (exception) {
108-
throw new ServerException('Failed to delete', exception);
109-
}
88+
await this.edgedb.run(query);
11089
}
11190
}

src/core/edgedb/error.util.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/core/edgedb/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export * from './reexports';
22
export { edgeql, EdgeQLArgsOf, EdgeQLReturnOf } from './edgeql';
33
export * from './edgedb.service';
44
export * from './withScope';
5-
export * from './error.util';
65
export * from './exclusivity-violation.error';

0 commit comments

Comments
 (0)