import json
import requests
from typing import OrderedDict


def resolve_reference(schema_url):
    """ Load and decode the schema from a given URL

    :param schema_url: the URL to the schema
    :return: an exception or a decoded json schema as a dictionary
    """
    try:
        return json.loads(requests.request('GET', schema_url).text, object_pairs_hook=OrderedDict)
    except Exception:
        return Exception