修复错误捕获

This commit is contained in:
2025-05-12 13:30:09 +08:00
parent 17bcb8787a
commit f1876e19bf

View File

@@ -24,7 +24,7 @@ export class UserService {
async create(user: Partial<User>): Promise<User> { async create(user: Partial<User>): Promise<User> {
try { try {
const newUser = this.userRepository.create(user); const newUser = this.userRepository.create(user);
return this.userRepository.save(newUser); return await this.userRepository.save(newUser);
} catch (error) { } catch (error) {
if (error instanceof QueryFailedError) { if (error instanceof QueryFailedError) {
throw new ConflictException(this.getDuplicateErrorMessage(error)); throw new ConflictException(this.getDuplicateErrorMessage(error));