Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/vendors/vendors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class VendorsService {

if (error) {
this.logger.error(`Failed to list vendors: ${error.message}`);
throw new Error('Failed to list vendors.');
throw new InternalServerErrorException('Failed to list vendors.');
}

const rows: VendorRow[] = (data ?? []) as VendorRow[];
Expand Down
24 changes: 16 additions & 8 deletions src/modules/vouching/vouching.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
Logger,
NotFoundException,
ConflictException,
BadRequestException,
InternalServerErrorException
} from '@nestjs/common';
import { SupabaseService } from '../../database/supabase.client';
import {
Expand Down Expand Up @@ -48,7 +50,7 @@ export class VouchingService {

if (existingError) {
this.logger.error(`Failed to check existing vouches: ${existingError.message}`);
throw new Error('Failed to check existing vouches.');
throw new InternalServerErrorException('Failed to check existing vouches.');
}

if (existing && existing.length > 0) {
Expand All @@ -73,10 +75,16 @@ export class VouchingService {
.select()
.single();

if (error || !data) {
this.logger.error(`Failed to insert vouch request: ${error?.message}`);
throw new Error('Failed to create vouch request.');
}
if (error) {
this.logger.error(`Failed to insert vouch request: ${error.message}`);
// Es un fallo del sistema/BD
throw new InternalServerErrorException('Failed to process vouch request internally.');
}
if (!data) {
this.logger.error(`Failed to insert vouch request: No data returned.`);
// Es un fallo por datos inválidos del cliente
throw new BadRequestException('Invalid vouch request data provided.');
}

this.logger.log(
`Vouch requested: learner=${learnerWallet} mentor=${dto.mentorWallet}`,
Expand Down Expand Up @@ -144,7 +152,7 @@ export class VouchingService {

if (error) {
this.logger.error(`Failed to list learner vouches for ${wallet}: ${error.message}`);
throw new Error('Failed to list vouches.');
throw new InternalServerErrorException('Failed to list vouches.');
}

const rows = (data ?? []) as VouchRow[];
Expand All @@ -162,7 +170,7 @@ export class VouchingService {

if (error) {
this.logger.error(`Failed to list mentor vouches for ${wallet}: ${error.message}`);
throw new Error('Failed to list vouches.');
throw new InternalServerErrorException('Failed to list vouches.');
}

const rows = (data ?? []) as VouchRow[];
Expand All @@ -181,7 +189,7 @@ export class VouchingService {

if (error) {
this.logger.error(`Failed to fetch incoming requests for ${mentorWallet}: ${error.message}`);
throw new Error('Failed to fetch vouch requests.');
throw new InternalServerErrorException('Failed to fetch vouch requests.');
}

const rows = data ?? [];
Expand Down