mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-15 04:59:42 +03:00
Can't finding post error
This commit is contained in:
@@ -55,7 +55,9 @@ export class PostService {
|
|||||||
async getPost(postId: string) {
|
async getPost(postId: string) {
|
||||||
try {
|
try {
|
||||||
this.logger.log(`[post.getPost] data: ${postId}`);
|
this.logger.log(`[post.getPost] data: ${postId}`);
|
||||||
return await this.postRepository.findOne({ where: { uuid: postId }, relations: { images: true } });
|
const post = await this.postRepository.findOne({ where: { uuid: postId }, relations: { images: true } });
|
||||||
|
if (!post) throw new Error("Can't find post");
|
||||||
|
return post;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.log(`[post.getPost] error: ${JSON.stringify(error)}`);
|
this.logger.log(`[post.getPost] error: ${JSON.stringify(error)}`);
|
||||||
throw new HttpException('No post with this id', HttpStatus.NOT_FOUND);
|
throw new HttpException('No post with this id', HttpStatus.NOT_FOUND);
|
||||||
@@ -65,7 +67,9 @@ export class PostService {
|
|||||||
async getByMediaGroup(mediaGroupId: string) {
|
async getByMediaGroup(mediaGroupId: string) {
|
||||||
try {
|
try {
|
||||||
this.logger.log(`[post.getByMediaGroup] data: ${mediaGroupId}`);
|
this.logger.log(`[post.getByMediaGroup] data: ${mediaGroupId}`);
|
||||||
return await this.postRepository.findOne({ where: { media_group_id: mediaGroupId } });
|
const post = await this.postRepository.findOne({ where: { media_group_id: mediaGroupId } });
|
||||||
|
if (!post) throw new Error("Can't find post");
|
||||||
|
return post;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.debug(`[post.getByMediaGroup] error: ${JSON.stringify(error)}`);
|
this.logger.debug(`[post.getByMediaGroup] error: ${JSON.stringify(error)}`);
|
||||||
throw new HttpException("Can't find post with this media group id", HttpStatus.BAD_REQUEST);
|
throw new HttpException("Can't find post with this media group id", HttpStatus.BAD_REQUEST);
|
||||||
|
|||||||
Reference in New Issue
Block a user