# Path: via/exceptions.py
# class BadURL(RequestBasedException):
#     """An invalid URL was discovered."""
# 
#     def __init__(self, message, requests_err=None, url=None):
#         super().__init__(message, requests_err)
#         self.url = url
# 
#     status_int = 400
# 
# class UnhandledUpstreamException(UpstreamServiceError):
#     """Something we did not plan for went wrong."""
# 
#     status_int = 417
# 
# class UpstreamServiceError(RequestBasedException):
#     """Something went wrong when calling an upstream service."""
# 
#     status_int = 409
# 
# class UpstreamTimeout(UpstreamServiceError):
#     """We timed out waiting for an upstream service."""
# 
#     # "504 - Gateway Timeout" is the correct thing to raise, but this
#     # will cause Cloudflare to intercept it:
#     # https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#502504error
#     # We're using "408 - Request Timeout" which is technically
#     # incorrect as it implies the user took too long, but has good semantics
#     status_int = 408


import requests
from requests import RequestException, exceptions
from via.exceptions import (
    BadURL,
    UnhandledUpstreamException,
    UpstreamServiceError,
    UpstreamTimeout,
)


DEFAULT_ERROR_MAP = {
    exceptions.MissingSchema: BadURL,
    exceptions.InvalidSchema: BadURL,
    exceptions.InvalidURL: BadURL,

# Path: via/exceptions.py
# class BadURL(RequestBasedException):
#     """An invalid URL was discovered."""
# 
#     def __init__(self, message, requests_err=None, url=None):
#         super().__init__(message, requests_err)
#         self.url = url
# 
#     status_int = 400
# 
# class UnhandledUpstreamException(UpstreamServiceError):
#     """Something we did not plan for went wrong."""
# 
#     status_int = 417
# 
# class UpstreamServiceError(RequestBasedException):
#     """Something went wrong when calling an upstream service."""
# 
#     status_int = 409
# 
# class UpstreamTimeout(UpstreamServiceError):
#     """We timed out waiting for an upstream service."""
# 
#     # "504 - Gateway Timeout" is the correct thing to raise, but this
#     # will cause Cloudflare to intercept it:
#     # https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#502504error
#     # We're using "408 - Request Timeout" which is technically
#     # incorrect as it implies the user took too long, but has good semantics
#     status_int = 408


# Path: via/services/http.py
import requests
from requests import RequestException, exceptions
from via.exceptions import (
    BadURL,
    UnhandledUpstreamException,
    UpstreamServiceError,
    UpstreamTimeout,
)



DEFAULT_ERROR_MAP = {
    exceptions.MissingSchema: BadURL,
    exceptions.InvalidSchema: BadURL,
    exceptions.InvalidURL: BadURL,

    exceptions.URLRequired: BadURL,