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

29 lines (28 loc) 1.44 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"); 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); } return new UnexpectedError_1.UnexpectedError(error); }