ó
Ò:\c           @   sG   d  Z  d d l m Z d   Z d   Z d   Z d   Z d   Z d S(	   s3   Navigator Exceptions and Exception handling module.iÿÿÿÿ(   t
   format_excc         C   s|   d d l  m } d j d |   } d j d |  } | GH| GH| d d d	 | d | d
 t d d  } | j d  | j   S(   s&   Display a Qt styled error message box.iÿÿÿÿ(   t   MessageBoxErrors=   An unexpected error occurred on Navigator start-up<br>{error}t   errors   {trace}t   tracet   titles   Navigator Start Errort   textt   reportt
   learn_moreiX  N(   t"   anaconda_navigator.widgets.dialogsR   t   formatt   Falset   Nonet   setFixedWidtht   exec_(   R   t	   tracebackR   R   R   t   msg_box(    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyt   display_qt_error_box   s    			c   	   
   C   sÅ   d } y d d l  m } Wn! t k
 r= d d l m } n Xd d l } | j d d  } t | d  & } | j | j d |  d	 |   Wd QXd
 j | |   } d d l	 } | j
 |  d S(   s7   Display a new browser window with an error description.sE  
    <html>
    <head>
      <title>Navigator Error</title>
    </head>
    <body>
      <div>
        <h1>Navigator Error</h1>
        <p>An unexpected error occurred on Navigator start-up</p>
        <h2>Report</h2>
        <p>Please report this issue in the anaconda
          <a href="https://github.com/continuumio/anaconda-issues">
            issue tracker
          </a>
        </p>
      </div>
      <div>
        <h2>Main Error</h2>
        <p><pre>{error}</pre></p>
        <h2>Traceback</h2>
        <p><pre>{trace}</pre></p>
      </div>
    </body>
    </html>
    iÿÿÿÿ(   t   pathname2urlNt   suffixs   .htmlt   wR   R   s   file:{}(   t   urllibR   t	   Exceptiont   urllib.requestt   tempfilet   mktempt   opent   writeR	   t
   webbrowsert   open_new_tab(	   R   R   t   templateR   R   t   temppatht   ft   urlR   (    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyt   display_browser_error_box   s    %c         O   sG   y& |  | |   } t  | t  r% | SWn t k
 rB } t |  SXd S(   s=   Handle global application exceptions and display information.N(   t
   isinstancet   intR   t   handle_exception(   t   funct   argst   kwargst   return_valuet   e(    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyt   exception_handlerH   s    c         O   s8   y |  | |   } | SWn t  k
 r3 } t |  SXd  S(   N(   R   R$   (   R%   R&   R'   t   valueR)   (    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyt   try_funcR   s
    c         C   s\   t    } y t |  |  Wn; t k
 rW y t |  |  WqX t k
 rS | GHqX Xn Xd S(   s=   This will provide a dialog for the user with the error found.N(   R    R   R   R!   (   R   R   (    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyR$   Z   s    	N(   t   __doc__R   R    R   R!   R*   R,   R$   (    (    (    s<   lib/python2.7/site-packages/anaconda_navigator/exceptions.pyt   <module>   s   		+	
	