feat(integration): improve integration test connection (#3005)

This commit is contained in:
Meier Lukas
2025-05-16 20:59:12 +02:00
committed by GitHub
parent 3daf1c8341
commit ef9a5e9895
111 changed files with 7168 additions and 976 deletions

View File

@@ -0,0 +1,26 @@
import { RequestError, ResponseError } from "@homarr/common/server";
import type { HttpErrorHandler } from "@homarr/common/server";
import type { IIntegrationErrorHandler } from "../handler";
import type { IntegrationError, IntegrationErrorData } from "../integration-error";
import { IntegrationRequestError } from "./integration-request-error";
import { IntegrationResponseError } from "./integration-response-error";
export class IntegrationHttpErrorHandler implements IIntegrationErrorHandler {
private readonly httpErrorHandler: HttpErrorHandler;
constructor(httpErrorHandler: HttpErrorHandler) {
this.httpErrorHandler = httpErrorHandler;
}
handleError(error: unknown, integration: IntegrationErrorData): IntegrationError | undefined {
if (error instanceof RequestError) return new IntegrationRequestError(integration, { cause: error });
if (error instanceof ResponseError) return new IntegrationResponseError(integration, { cause: error });
const requestError = this.httpErrorHandler.handleRequestError(error);
if (requestError) return new IntegrationRequestError(integration, { cause: requestError });
const responseError = this.httpErrorHandler.handleResponseError(error);
if (responseError) return new IntegrationResponseError(integration, { cause: responseError });
return undefined;
}
}