/*
 Copyright (C) 2015, 2025 3NSoft Inc.
 
 This program is free software: you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation, either version 3 of the License, or (at your option) any later
 version.
 
 This program is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 See the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License along with
 this program. If not, see <http://www.gnu.org/licenses/>. */

import { makeRuntimeException } from "./runtime";

export type ConnectException = web3n.HTTPConnectException;
export type HTTPException = web3n.HTTPException;

export function makeConnectionException(
	url: string|undefined, method: string|undefined,
	message?: string, cause?: any
): ConnectException {
	return makeRuntimeException<ConnectException>(
		'connect', { connectType: 'http', url, method, cause, message }, {}
	);
}

export function makeHTTPException(
	url: string, method: string, status: number, message?: string, cause?: any
): HTTPException {
	return makeRuntimeException<HTTPException>(
		'http-request', { url, method, status, cause, message }, {}
	);
}

Object.freeze(exports);