Skip to content

Commit

Permalink
fix: throwing the errors instead of returning them (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedzaher authored May 16, 2024
1 parent 9128b04 commit e303155
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
28 changes: 1 addition & 27 deletions src/events/channels.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ForbiddenException,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { ChannelsService } from 'src/channels/channels.service';
import { ChannelDeletedDto } from './dto/channel-deleted.dto';
import { EventReplyDto } from './dto/event-reply.dto';
Expand Down Expand Up @@ -114,28 +110,6 @@ export class ChannelsEventService {
payload.data,
);

if (result instanceof NotFoundException) {
return {
status: 'FAILED',
error: {
id: '404',
message: 'Not Found',
},
seq_reply: payload.seq,
};
}

if (result instanceof ForbiddenException) {
return {
status: 'FAILED',
error: {
id: '403',
message: 'Forbidden',
},
seq_reply: payload.seq,
};
}

if (!result) {
return {
status: 'FAILED',
Expand Down
4 changes: 2 additions & 2 deletions src/workspace-channel/workspace-channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export class WorkspaceChannelService {
) {
const channel = await this.channelsService.getChannelById(user, channelId);
if (!channel) {
return new NotFoundException();
throw new NotFoundException();
}
if (channel.owner.id !== user.id) {
return new ForbiddenException();
throw new ForbiddenException();
}

const usersToAdd = await this.getWorkspaceMembers(data.users, workspaceId);
Expand Down
2 changes: 1 addition & 1 deletion src/workspaces/workspaces.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class WorkspacesService {
async getWorkspace(id: Workspace['id']) {
const workspace = await this.workspaceRepository.findOne({ id });
if (!workspace) {
return new NotFoundException();
throw new NotFoundException();
}
return workspace;
}
Expand Down

0 comments on commit e303155

Please sign in to comment.