feat: console error
This commit is contained in:
parent
b4beee65da
commit
c84d8af915
|
|
@ -290,17 +290,6 @@ export class PostsService {
|
|||
return this.postSocial(integration, posts, true);
|
||||
}
|
||||
|
||||
if (
|
||||
err instanceof BadBody &&
|
||||
process.env.EMAIL_FROM_ADDRESS === 'nevo@postiz.com'
|
||||
) {
|
||||
await this._notificationService.sendEmail(
|
||||
'nevo@positz.com',
|
||||
'Bad body',
|
||||
JSON.stringify(err.body)
|
||||
);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
export class RefreshToken {}
|
||||
export class RefreshToken {
|
||||
constructor(public json: string, public body: BodyInit) {}
|
||||
}
|
||||
export class BadBody {
|
||||
constructor(public body: BodyInit) {
|
||||
}
|
||||
constructor(public json: string, public body: BodyInit) {}
|
||||
}
|
||||
|
||||
export class NotEnoughScopes {}
|
||||
|
|
@ -10,20 +11,23 @@ export abstract class SocialAbstract {
|
|||
async fetch(url: string, options: RequestInit = {}) {
|
||||
const request = await fetch(url, options);
|
||||
|
||||
if (request.status !== 200 && request.status !== 201) {
|
||||
try {
|
||||
console.log(await request.json());
|
||||
}
|
||||
catch (err) {
|
||||
console.log('skip');
|
||||
}
|
||||
if (request.status === 200 || request.status === 201) {
|
||||
return request;
|
||||
}
|
||||
|
||||
let json = '{}';
|
||||
try {
|
||||
json = await request.json();
|
||||
} catch (err) {
|
||||
json = '{}';
|
||||
}
|
||||
|
||||
if (request.status === 401) {
|
||||
throw new RefreshToken();
|
||||
throw new RefreshToken(json, options.body!);
|
||||
}
|
||||
|
||||
if (request.status === 400) {
|
||||
throw new BadBody(options.body!);
|
||||
throw new BadBody(json, options.body!);
|
||||
}
|
||||
|
||||
return request;
|
||||
|
|
|
|||
Loading…
Reference in New Issue