feat: Capture unhandled errors by restructuring apps
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user