<!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>Catching Gdata Exceptions &mdash; Zend Framework 2 2.3.0dev documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.3.0dev',
        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="Zend Framework 2 2.3.0dev documentation" href="../index.html" />
<style type="text/css">
    /* Styles for floating Edit on GitHub box */
    #editor-trap {
        padding: 1em;
        border: 1px solid white;
        width: 250px;

        display: none;
        color: white;
        background: #3f454b;
        position: fixed;
        bottom: 5px;
        left: 175px;
        font-size: 85%;
        text-align: left;
        z-index: 2;

        box-shadow: 0 4px 6px #333;
        -moz-box-shadow: 0 4px 6px #333;
        -webkit-box-shadow: 0 4px 6px #333;
        
        cursor: pointer;
    }

    #editor-trap h3 {
        margin: 0 0 0.5em 0;
        padding: 0;
    }

    #editor-trap h3 > span {
        padding: 0 6px;
        border: solid white;
        border-width: 0 1px 4px 1px;
        font-size: 10px;
    }

    #editor-trap a {
        color: #98DBCC;
    }

    #editor-trap ol {
        margin: 0;
        padding: 0 0 0 2em;
    }

    /* Hide trick */
    #editor-trap.toggled > * {
        display: none;
    }


    #editor-trap.toggled > h3 {
        display: block;
    }

    #editor-trap.toggled > h3 > span {
        border-width: 6px 1px 0 1px;
    }
    
    #edit-button {
        position: fixed;
        bottom: 5px;
        left: 5px;
        z-index: 2;
        width: 162px;
        height: 42px;
    }
</style>

  </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><a href="../index.html">Zend Framework 2 2.3.0dev documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="catching-gdata-exceptions">
<span id="zendgdata-exception"></span><h1>Catching Gdata Exceptions<a class="headerlink" href="#catching-gdata-exceptions" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="docutils literal"><span class="pre">ZendGData\App\Exception</span></tt> class is a base class for exceptions thrown by <tt class="docutils literal"><span class="pre">ZendGData</span></tt>. You can catch any
exception thrown by <tt class="docutils literal"><span class="pre">ZendGData</span></tt> by catching <tt class="docutils literal"><span class="pre">ZendGData\App\Exception</span></tt>.</p>
<div class="highlight-php"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">try</span> <span class="p">{</span>
    <span class="nv">$client</span> <span class="o">=</span>
        <span class="nx">ZendGData\ClientLogin</span><span class="o">::</span><span class="na">getHttpClient</span><span class="p">(</span><span class="nv">$username</span><span class="p">,</span> <span class="nv">$password</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ZendGData\App\Exception</span> <span class="nv">$ex</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Report the exception to the user</span>
    <span class="k">die</span><span class="p">(</span><span class="nv">$ex</span><span class="o">-&gt;</span><span class="na">getMessage</span><span class="p">());</span>
<span class="p">}</span>
</pre></div>
</td></tr></table></div>
<p>The following exception subclasses are used by <tt class="docutils literal"><span class="pre">ZendGData</span></tt>:</p>
<blockquote>
<div><ul class="simple">
<li><tt class="docutils literal"><span class="pre">ZendGData\App\AuthException</span></tt> indicates that the user&#8217;s account credentials were not valid.</li>
<li><tt class="docutils literal"><span class="pre">ZendGData\App\BadMethodCallException</span></tt> indicates that a method was called for a service that does not
support the method. For example, the CodeSearch service does not support <tt class="docutils literal"><span class="pre">post()</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">ZendGData\App\HttpException</span></tt> indicates that an <em>HTTP</em> request was not successful. Provides the ability to
get the full <tt class="docutils literal"><span class="pre">Zend\Http\Response</span></tt> object to determine the exact cause of the failure in cases where
<tt class="docutils literal"><span class="pre">$e-&gt;getMessage()</span></tt> does not provide enough details.</li>
<li><tt class="docutils literal"><span class="pre">ZendGData\App\InvalidArgumentException</span></tt> is thrown when the application provides a value that is not valid
in a given context. For example, specifying a Calendar visibility value of &#8220;banana&#8221;, or fetching a Blogger
feed without specifying any blog name.</li>
<li><tt class="docutils literal"><span class="pre">ZendGData\App\CaptchaRequiredException</span></tt> is thrown when a ClientLogin attempt receives a CAPTCHA(tm)
challenge from the authentication service. This exception contains a token ID and a <em>URL</em> to a CAPTCHA(tm)
challenge image. The image is a visual puzzle that should be displayed to the user. After collecting the
user&#8217;s response to the challenge image, the response can be included with the next ClientLogin attempt.The
user can alternatively be directed to this website: <a class="reference external" href="https://www.google.com/accounts/DisplayUnlockCaptcha">https://www.google.com/accounts/DisplayUnlockCaptcha</a>
Further information can be found in the <a class="reference internal" href="zendgdata.client-login.html#zendgdata-clientlogin"><em>ClientLogin documentation</em></a>.</li>
</ul>
</div></blockquote>
<p>You can use these exception subclasses to handle specific exceptions differently. See the <em>API</em> documentation for
information on which exception subclasses are thrown by which methods in <tt class="docutils literal"><span class="pre">ZendGData</span></tt>.</p>
<div class="highlight-php"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">try</span> <span class="p">{</span>
    <span class="nv">$client</span> <span class="o">=</span> <span class="nx">ZendGData\ClientLogin</span><span class="o">::</span><span class="na">getHttpClient</span><span class="p">(</span><span class="nv">$username</span><span class="p">,</span>
                                                    <span class="nv">$password</span><span class="p">,</span>
                                                    <span class="nv">$service</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ZendGData\App\AuthException</span> <span class="nv">$authEx</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// The user&#39;s credentials were incorrect.</span>
    <span class="c1">// It would be appropriate to give the user a second try.</span>
    <span class="o">...</span>
<span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="nx">ZendGData\App\HttpException</span> <span class="nv">$httpEx</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Google Data servers cannot be contacted.</span>
    <span class="k">die</span><span class="p">(</span><span class="nv">$httpEx</span><span class="o">-&gt;</span><span class="na">getMessage</span><span class="p">);}</span>
</pre></div>
</td></tr></table></div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/zf2_logo.png" alt="Logo"/>
            </a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li>
        <!--<a href="../_sources/modules/zendgdata.exception.txt"-->
        <a href="https://github.com/zendframework/zf2-documentation/blob/master/docs/languages/en/modules/zendgdata.exception.rst"
           rel="nofollow">Show Source</a></li>
    <li><a href="https://github.com/zendframework/zf2-documentation/edit/master/docs/languages/en/modules/zendgdata.exception.rst"
           rel="nofollow">Edit Source</a>
    </li>
  </ul>
        <p style="font-size: 12px">
            Note: You need to stay logged into your <a href="http://www.github.com">GitHub account</a> to contribute to the documentation.
        </p>
<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><a href="../index.html">Zend Framework 2 2.3.0dev documentation</a> &raquo;</li> 
      </ul>
    </div>

    <div class="footer">
        &copy; Copyright 2013, Zend Technologies Ltd..
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b3.
    </div>
<div id="edit-button">
    <img src="../_static/edit.gif" alt="Edit this document" title="Edit this document" onclick="javascript:$('#editor-trap').toggle();">
</div>
     
<div id="editor-trap">
    <h3>Edit this document</h3>

    <p>
        The source code of this file is hosted on GitHub. Everyone can
        update and fix errors in this document with few clicks -
        no downloads needed.
    <p>

    <ol>

        <li>
            Login with your <a href="http://www.github.com">GitHub</a> account.
        </li>

        <li>
            Go to
            <a href="https://github.com/zendframework/zf2-documentation/edit/master/docs/languages/en/modules/zendgdata.exception.rst">
                Catching Gdata Exceptions
            </a> on GitHub.
        </li>

        <li>
            Edit file contents using GitHub's text editor in your web browser
        </li>

        <li>
            Fill in the <b>Commit message</b> text box at the end of the page telling <i>why</i>
            you did the changes. Press <b>Propose file change</b> button next to it when done.
        </li>


        <li>
            On <i>Send a pull request</i> page you don't need to fill in text anymore. Just
            press <b>Send pull request</b> button.
        </li>

        <li>
            Your changes are now queued for review under project's <a href="https://github.com/zendframework/zf2-documentation/pulls">Pull requests</a> tab on GitHub.
        </li>
    </ol>

</div>


  </body>
</html>