feat: Capture unhandled errors by restructuring apps

This commit is contained in:
Faruk AYDIN
2022-10-21 19:03:24 +02:00
parent 525472d3e0
commit 9a743fb4a8
16 changed files with 92 additions and 76 deletions

View File

@@ -1,13 +1,16 @@
import { IGlobalVariable, IJSONObject } from "@automatisch/types";
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
import type { AxiosResponse } from 'axios';
import parseLinkHeader from '../../../helpers/parse-header-link';
type TResponse = {
data: IJSONObject[],
error?: IJSONObject,
}
data: IJSONObject[];
error?: IJSONObject;
};
export default async function paginateAll($: IGlobalVariable, request: Promise<AxiosResponse>) {
export default async function paginateAll(
$: IGlobalVariable,
request: Promise<AxiosResponse>
) {
const response = await request;
const aggregatedResponse: TResponse = {
data: [...response.data],
@@ -21,8 +24,8 @@ export default async function paginateAll($: IGlobalVariable, request: Promise<A
url: links.next.uri,
});
if (nextPageResponse.integrationError) {
aggregatedResponse.error = nextPageResponse.integrationError;
if (nextPageResponse.httpError) {
aggregatedResponse.error = nextPageResponse.httpError;
links = null;
} else {