//#region src/libs/errors.ts
/** Centralized list of all error messages */
var ERRORS = {
	BUILDING_REQUEST_FAILED: "An error occurred while building the request",
	DEFAULT: "An unknown error has occurred.",
	INVALID_URL: "The URL seems to be invalid. Try adding a valid URL.",
	INVALID_HEADER: "There is an invalid header present, please double check your params.",
	MISSING_FILE: "File uploads are not saved in history, you must re-upload the file.",
	REQUEST_ABORTED: "The request has been cancelled",
	REQUEST_FAILED: "An error occurred while making the request",
	URL_EMPTY: "The address bar input seems to be empty. Try adding a URL.",
	ON_BEFORE_REQUEST_FAILED: "onBeforeRequest request hook failed"
};
/** Normalizes caught error into an error instance */
var normalizeError = (e, defaultMessage = ERRORS.DEFAULT) => {
	console.error(e);
	if (e instanceof Error) {
		e.message = prettyErrorMessage(e.message);
		return e;
	}
	if (typeof e === "string") return new Error(prettyErrorMessage(e));
	return new Error(defaultMessage);
};
/** Takes javascript errors and returns a prettier message */
var prettyErrorMessage = (message) => {
	if (message === `Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.`) return ERRORS.MISSING_FILE;
	if (message === `Failed to construct 'URL': Invalid URL`) return ERRORS.INVALID_URL;
	if (message === `Failed to execute 'fetch' on 'Window': Invalid name`) return ERRORS.INVALID_HEADER;
	return message;
};
//#endregion
export { ERRORS, normalizeError, prettyErrorMessage };

//# sourceMappingURL=errors.js.map