
try:
    from .modules import *
except ValueError:
    from modules import *


def plugin_loaded():
    """Plugin loaded callback."""
    try:
        # Reload 'modules' once after upgrading to ensure GitGutter is ready
        # for use instantly again. (Works with ST3 and python3 only!)
        from package_control import events
        if events.post_upgrade(__package__):
            from .modules.reload import reload_package
            reload_package(__package__)
    except ImportError:
        # Fail silently if package control isn't installed.
        pass


try:
    from .modules import *
except ValueError:
    from modules import *
except ImportError:
    # Failed to import at least one module. This can happen after upgrade due
    # to internal structure changes.
    import sublime
    sublime.message_dialog(
        "GitGutter failed to reload some of its modules.\n"
        "Please restart Sublime Text!")


def plugin_loaded():
    """Plugin loaded callback."""
    try:
        # Reload 'modules' once after upgrading to ensure GitGutter is ready
        # for use instantly again. (Works with ST3 and python3 only!)
        from package_control import events
        if events.post_upgrade(__package__):
            from .modules.reload import reload_package
            reload_package(__package__)
    except ImportError:
        # Fail silently if package control isn't installed.
        pass

Handle module reload exceptions gracefully
Enhancement: Handle module reload exceptions gracefully

In some rare cases if the internal module structure has changed the 'reload' module can't recover all modules and will fail with ImportError. This is the situation we need to advice a restart of Sublime Text.

  
  try:
      from .modules import *
  except ValueError:
      from modules import *
+ except ImportError:
+     # Failed to import at least one module. This can happen after upgrade due
+     # to internal structure changes.
+     import sublime
+     sublime.message_dialog(
+         "GitGutter failed to reload some of its modules.\n"
+         "Please restart Sublime Text!")
  
  
  def plugin_loaded():
      """Plugin loaded callback."""
      try:
          # Reload 'modules' once after upgrading to ensure GitGutter is ready
          # for use instantly again. (Works with ST3 and python3 only!)
          from package_control import events
          if events.post_upgrade(__package__):
              from .modules.reload import reload_package
              reload_package(__package__)
      except ImportError:
          # Fail silently if package control isn't installed.
          pass
  
Handle module reload exceptions gracefully
## Code Before:

try:
    from .modules import *
except ValueError:
    from modules import *


def plugin_loaded():
    """Plugin loaded callback."""
    try:
        # Reload 'modules' once after upgrading to ensure GitGutter is ready
        # for use instantly again. (Works with ST3 and python3 only!)
        from package_control import events
        if events.post_upgrade(__package__):
            from .modules.reload import reload_package
            reload_package(__package__)
    except ImportError:
        # Fail silently if package control isn't installed.
        pass

## Instruction:
Handle module reload exceptions gracefully
## Code After:

try:
    from .modules import *
except ValueError:
    from modules import *
except ImportError:
    # Failed to import at least one module. This can happen after upgrade due
    # to internal structure changes.
    import sublime
    sublime.message_dialog(
        "GitGutter failed to reload some of its modules.\n"
        "Please restart Sublime Text!")


def plugin_loaded():
    """Plugin loaded callback."""
    try:
        # Reload 'modules' once after upgrading to ensure GitGutter is ready
        # for use instantly again. (Works with ST3 and python3 only!)
        from package_control import events
        if events.post_upgrade(__package__):
            from .modules.reload import reload_package
            reload_package(__package__)
    except ImportError:
        # Fail silently if package control isn't installed.
        pass
