Skip to content

Commit

Permalink
feat: set catch in db calls
Browse files Browse the repository at this point in the history
  • Loading branch information
wandersonDeve committed Oct 1, 2023
1 parent 8803086 commit 0da75b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { EntityRepository, Repository } from 'typeorm';
import { ApplicationEntity } from '../../../database/entities/applications.entity';
import { handleError } from '../../../shared/utils/handle-error.util';

@EntityRepository(ApplicationEntity)
export class ApplicationsRepository extends Repository<ApplicationEntity> {
async saveApplication(data: any): Promise<ApplicationEntity> {
return this.save(data);
return this.save(data).catch(handleError);
}
}
4 changes: 2 additions & 2 deletions src/modules/company/repository/company-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UpdateMyPasswordDto } from '../dtos/update-my-password.dto';
export class CompanyRepository extends Repository<CompaniesEntity> {
async createCompany(data: CreateCompanyDto): Promise<CompaniesEntity> {
delete data.passwordConfirmation;
return this.save(data);
return this.save(data).catch(handleError);
}

async findAllCompany(
Expand Down Expand Up @@ -89,7 +89,7 @@ export class CompanyRepository extends Repository<CompaniesEntity> {

company.recoverPasswordToken = recoverPasswordToken;

await this.save(company);
await this.save(company).catch(handleError);

return company;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/jobs/repository/job.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class JobRepository extends Repository<JobsEntity> {
])
.where('jobs.id = :id', { id });

return queryBuilder.getOne();
return queryBuilder.getOne().catch(handleError);
}

async updateJob(id: string, data: UpdateJobDto) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/repository/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class UserRepository extends Repository<UsersEntity> {

user.mailConfirm = true;

await this.update(id, { mailConfirm: true });
await this.update(id, { mailConfirm: true }).catch(handleError);

return this.findOne(id);
}
Expand Down

0 comments on commit 0da75b7

Please sign in to comment.