1# Copyright 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6class NativeBrowserCrashException(Exception): 7 def __init__(self, browser=None, msg=''): 8 super(NativeBrowserCrashException, self).__init__(msg) 9 self._browser = browser 10 self._msg = msg 11 12 def __str__(self): 13 if not self._browser: 14 return super(NativeBrowserCrashException, self).__str__() 15 divider = '*' * 80 16 return '%s\nStack Trace:\n%s\n\t%s\n%s' % ( 17 super(NativeBrowserCrashException, self).__str__(), divider, 18 self._browser.GetStackTrace().replace('\n', '\n\t'), divider) 19 20 21class TabCrashException(NativeBrowserCrashException): 22 """Represents a crash of the current tab, but not the overall browser. 23 24 In this state, the tab is gone, but the underlying browser is still alive.""" 25 def __init__(self, browser, msg='Tab crashed'): 26 super(TabCrashException, self).__init__(browser, msg) 27 28 29class BrowserGoneException(NativeBrowserCrashException): 30 """Represents a crash of the entire browser. 31 32 In this state, all bets are pretty much off.""" 33 def __init__(self, browser, msg='Browser crashed'): 34 super(BrowserGoneException, self).__init__(browser, msg) 35 36 37class BrowserConnectionGoneException(BrowserGoneException): 38 """Represents a browser that still exists but cannot be reached.""" 39 def __init__(self, browser, msg='Browser exists but the connection is gone'): 40 super(BrowserConnectionGoneException, self).__init__(browser, msg) 41 42 43class ProcessGoneException(Exception): 44 """Represents a process that no longer exists for an unknown reason.""" 45 46 47class IntentionalException(Exception): 48 """Represent an exception raised by a unittest which is not printed.""" 49 50 51class LoginException(Exception): 52 pass 53 54 55class EvaluateException(Exception): 56 pass 57 58 59class ProfilingException(Exception): 60 pass 61