1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-22 17:39:59 -05:00
vsphere-automation-sdk-python/vsphere/6.0/_modules/vmware/vapi/exception.html

173 lines
12 KiB
HTML
Raw Normal View History

2018-08-07 19:42:25 -04:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>vmware.vapi.exception &mdash; vCloud Suite SDK for Python 6.0.0 documentation</title>
<link rel="stylesheet" href="../../../_static/vapitheme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '6.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="vCloud Suite SDK for Python 6.0.0 documentation" href="../../../index.html" />
<link rel="up" title="Module code" href="../../index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li><a href="../../../index.html">vCloud Suite SDK for Python 6.0.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Source code for vmware.vapi.exception</h1><div class="highlight"><pre>
<span class="c">#!/usr/bin/env python</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">vAPI CoreException Class</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="n">__author__</span> <span class="o">=</span> <span class="s">&#39;VMware, Inc.&#39;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s">&#39;Copyright 2011-2012 VMware, Inc. All rights reserved. -- VMware Confidential&#39;</span>
<span class="c"># The plan is to rename this to VapiException once the original VapiException</span>
<span class="c"># (above) is eliminated.</span>
<div class="viewcode-block" id="CoreException"><a class="viewcode-back" href="../../../vmware.vapi.html#vmware.vapi.exception.CoreException">[docs]</a><span class="k">class</span> <span class="nc">CoreException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This exception is raised by various components of the vAPI runtime</span>
<span class="sd"> infrastructure to indicate failures in that infrastructure.</span>
<span class="sd"> Server-side the exception is caught by specific components and an</span>
<span class="sd"> internal_server_error is reported to the client that invoked the</span>
<span class="sd"> request. Client-side the exception may be raised for certain failures</span>
<span class="sd"> before a request was sent to the server or after the response was</span>
<span class="sd"> received from the server. Similarly, server-side the exception may</span>
<span class="sd"> be raised for failures that occur when a provider implementation</span>
<span class="sd"> invokes the vAPI runtime.</span>
<span class="sd"> This exception is not part of the vAPI message protocol, and it must</span>
<span class="sd"> never be raised by provider implementations.</span>
<span class="sd"> :type messages: generator of :class:`vmware.vapi.message.Message`</span>
<span class="sd"> :ivar messages: Generator of error messages describing why the Exception</span>
<span class="sd"> was raised</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="n">cause</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Initialize CoreException</span>
<span class="sd"> :type message: :class:`vmware.vapi.message.Message`</span>
<span class="sd"> :param message: Description regarding why the Exception was raised</span>
<span class="sd"> :type cause: :class:`Exception`</span>
<span class="sd"> :type cause: Exception that led to this Exception</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="ne">Exception</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">message</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_message</span> <span class="o">=</span> <span class="n">message</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cause</span> <span class="o">=</span> <span class="n">cause</span>
<span class="nd">@property</span>
<div class="viewcode-block" id="CoreException.messages"><a class="viewcode-back" href="../../../vmware.vapi.html#vmware.vapi.exception.CoreException.messages">[docs]</a> <span class="k">def</span> <span class="nf">messages</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> :rtype: generator of :class:`vmware.vapi.message.Message`</span>
<span class="sd"> :return: Generator of error messages describing why the Exception</span>
<span class="sd"> was raised</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">e</span> <span class="o">=</span> <span class="bp">self</span>
<span class="k">while</span> <span class="n">e</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">yield</span> <span class="n">e</span><span class="o">.</span><span class="n">_message</span> <span class="c"># pylint: disable=W0212</span>
<span class="n">e</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">_cause</span> <span class="c"># pylint: disable=W0212</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="n">e</span> <span class="o">=</span> <span class="bp">None</span>
<span class="c"># This method is primarily for use in tests</span></div>
<span class="k">def</span> <span class="nf">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
<span class="k">return</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">CoreException</span><span class="p">)</span> <span class="ow">and</span>
<span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">messages</span><span class="p">)</span> <span class="o">==</span> <span class="nb">list</span><span class="p">(</span><span class="n">other</span><span class="o">.</span><span class="n">messages</span><span class="p">)))</span>
<span class="k">def</span> <span class="nf">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
<span class="k">return</span> <span class="ow">not</span> <span class="p">(</span><span class="bp">self</span> <span class="o">==</span> <span class="n">other</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">result</span> <span class="o">=</span> <span class="ne">Exception</span><span class="o">.</span><span class="n">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cause</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">cause_class</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cause</span><span class="o">.</span><span class="n">__class__</span>
<span class="n">cause_class_name</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">.</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cause_class</span><span class="o">.</span><span class="n">__module__</span><span class="p">,</span>
<span class="n">cause_class</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">, </span><span class="se">\n\t</span><span class="s">Caused by: </span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">result</span><span class="p">,</span>
<span class="n">cause_class_name</span><span class="p">,</span>
<span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cause</span><span class="p">))</span>
<span class="k">return</span> <span class="n">result</span></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li><a href="../../../index.html">vCloud Suite SDK for Python 6.0.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Module code</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2014, VMware, Inc..
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>