UNPKG

@telefonica/confluence-sync

Version:

Creates/updates/deletes Confluence pages based on a list of objects containing the page contents. Supports nested pages and attachments upload

33 lines (32 loc) 1.58 kB
"use strict"; // SPDX-FileCopyrightText: 2024 Telefónica Innovación Digital // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.toConfluenceClientError = toConfluenceClientError; const axios_1 = require("axios"); const BadRequestError_1 = require("./axios/BadRequestError"); const InternalServerError_1 = require("./axios/InternalServerError"); const UnauthorizedError_1 = require("./axios/UnauthorizedError"); const UnexpectedError_1 = require("./axios/UnexpectedError"); const UnknownAxiosError_1 = require("./axios/UnknownAxiosError"); const UnknownError_1 = require("./UnknownError"); function toConfluenceClientError(error) { if (error.name === "AxiosError") { const axiosError = error; if (axiosError.response?.status === axios_1.HttpStatusCode.BadRequest) { return new BadRequestError_1.BadRequestError(axiosError); } if (axiosError.response?.status === axios_1.HttpStatusCode.Unauthorized || axiosError.response?.status === axios_1.HttpStatusCode.Forbidden) { return new UnauthorizedError_1.UnauthorizedError(axiosError); } if (axiosError.response?.status === axios_1.HttpStatusCode.InternalServerError) { return new InternalServerError_1.InternalServerError(axiosError); } return new UnknownAxiosError_1.UnknownAxiosError(axiosError); } if (!error) { return new UnknownError_1.UnknownError(); } return new UnexpectedError_1.UnexpectedError(error.message || error); }