Skip to content

Commit c84d8af

Browse files
author
Nevo David
committed
feat: console error
1 parent b4beee6 commit c84d8af

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,6 @@ export class PostsService {
290290
return this.postSocial(integration, posts, true);
291291
}
292292

293-
if (
294-
err instanceof BadBody &&
295-
process.env.EMAIL_FROM_ADDRESS === 'nevo@postiz.com'
296-
) {
297-
await this._notificationService.sendEmail(
298-
'nevo@positz.com',
299-
'Bad body',
300-
JSON.stringify(err.body)
301-
);
302-
}
303-
304293
throw err;
305294
}
306295
}

libraries/nestjs-libraries/src/integrations/social.abstract.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
export class RefreshToken {}
1+
export class RefreshToken {
2+
constructor(public json: string, public body: BodyInit) {}
3+
}
24
export class BadBody {
3-
constructor(public body: BodyInit) {
4-
}
5+
constructor(public json: string, public body: BodyInit) {}
56
}
67

78
export class NotEnoughScopes {}
@@ -10,20 +11,23 @@ export abstract class SocialAbstract {
1011
async fetch(url: string, options: RequestInit = {}) {
1112
const request = await fetch(url, options);
1213

13-
if (request.status !== 200 && request.status !== 201) {
14-
try {
15-
console.log(await request.json());
16-
}
17-
catch (err) {
18-
console.log('skip');
19-
}
14+
if (request.status === 200 || request.status === 201) {
15+
return request;
2016
}
17+
18+
let json = '{}';
19+
try {
20+
json = await request.json();
21+
} catch (err) {
22+
json = '{}';
23+
}
24+
2125
if (request.status === 401) {
22-
throw new RefreshToken();
26+
throw new RefreshToken(json, options.body!);
2327
}
2428

2529
if (request.status === 400) {
26-
throw new BadBody(options.body!);
30+
throw new BadBody(json, options.body!);
2731
}
2832

2933
return request;

0 commit comments

Comments
 (0)