|
|
@@ -27,10 +27,10 @@ export class ManufacturerService {
|
|
|
} catch (err) {
|
|
|
throw new HttpException(
|
|
|
{
|
|
|
- status: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
|
- error: 'This is a custom message',
|
|
|
+ status: HttpStatus.BAD_REQUEST,
|
|
|
+ error: err?.driverError?.detail,
|
|
|
},
|
|
|
- HttpStatus.FORBIDDEN,
|
|
|
+ HttpStatus.BAD_REQUEST,
|
|
|
{
|
|
|
cause: err,
|
|
|
},
|
|
|
@@ -46,14 +46,44 @@ export class ManufacturerService {
|
|
|
code,
|
|
|
});
|
|
|
|
|
|
- return await this.manufacturerRepository.save(manufacturer);
|
|
|
+ try {
|
|
|
+ return await this.manufacturerRepository.save(manufacturer);
|
|
|
+ } catch (err) {
|
|
|
+ throw new HttpException(
|
|
|
+ {
|
|
|
+ status: HttpStatus.BAD_REQUEST,
|
|
|
+ error: err?.driverError?.detail,
|
|
|
+ },
|
|
|
+ HttpStatus.BAD_REQUEST,
|
|
|
+ {
|
|
|
+ cause: err,
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- async fineById(id: string): Promise<Manufacturer | null> {
|
|
|
+ async findById(id: string): Promise<Manufacturer | null> {
|
|
|
return await this.manufacturerRepository.findOneOrFail({
|
|
|
where: {
|
|
|
id: id,
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ async findAll(): Promise<Manufacturer[]> {
|
|
|
+ try {
|
|
|
+ return await this.manufacturerRepository.find();
|
|
|
+ } catch (err) {
|
|
|
+ throw new HttpException(
|
|
|
+ {
|
|
|
+ status: HttpStatus.BAD_REQUEST,
|
|
|
+ error: err?.driverError?.detail,
|
|
|
+ },
|
|
|
+ HttpStatus.BAD_REQUEST,
|
|
|
+ {
|
|
|
+ cause: err,
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|