<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Error Condition Mappings</title>
  <abstract>A mapping to enable legacy entities to correctly handle errors from XMPP-aware entities.</abstract>
  &LEGALNOTICE;
  <number>0086</number>
  <status>Deprecated</status>
  <type>Informational</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>N/A</shortname>
  <author>
    <firstname>Robert</firstname>
    <surname>Norris</surname>
    <email>rob@cataclysm.cx</email>
    <jid>rob@cataclysm.cx</jid>
  </author>
  &stpeter;
  <revision>
    <version>1.0</version>
    <date>2004-02-17</date>
    <initials>psa</initials>
    <remark>Per a vote of the Jabber Council, advanced status to Active.</remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2003-11-26</date>
    <initials>psa</initials>
    <remark>Added &lt;not-authorized/&gt; condition.</remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2003-11-25</date>
    <initials>psa</initials>
    <remark>Corrected 'type' of &lt;not-acceptable/&gt; error from "cancel" to "modify".</remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2003-11-17</date>
    <initials>psa</initials>
    <remark>Fixed a syntax error.</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2003-10-30</date>
    <initials>psa</initials>
    <remark>Added &lt;gone/&gt; XMPP condition.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-09-25</date>
    <initials>psa</initials>
    <remark>Further updated to track XMPP WG output; fixed several errors.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-08-13</date>
    <initials>psa</initials>
    <remark>Updated to track XMPP WG output.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-05-21</date>
    <initials>rn</initials>
    <remark>Initial release.</remark>
  </revision>
</header>
<section1 topic='Introduction'>
  <p>&xmppcore; documents formats and semantics for stanza error responses. The XML of these errors is different from that of errors that have been traditionally used on the Jabber network.</p>
  <p>Until such time that all entities support these new XMPP-style errors, there is a need for entities to issue errors that are understandable by both legacy and XMPP-compliant entities. This document outlines an appropriate mapping to allow this to occur.</p>
  <p>This document can also be used by implementers of legacy protocols to determine which XMPP-style error should be used when only a legacy error code is documented.</p>
</section1>
<section1 topic='Supporting Legacy Entities'>
  <p>XMPP-compliant entities can issue errors to legacy clients and servers by adding a &quot;code&quot; attribute to the &lt;error/&gt; element it sends.</p>
  <example caption='A simple error response'><![CDATA[
<message
    to='juliet@capulet.com/balcony'
    from='romeo@montague.net/garden'
    type='error'>
  <body>Wherefore art thou, Romeo?</body>
  <error code='404' type='cancel'>
    <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</message>
]]></example>

  <p>Legacy entities receiving this error will use the &quot;404&quot; to determine what happened, while XMPP-compliant entities will use the error type and the child element that specifies the condition.</p>

  <p>XMPP-compliant entities should add the following error codes to errors if they want them to be understood by legacy entities:</p>

  <table caption='Error codes to add to XMPP-style errors'>
    <tr>
      <th>XMPP error condition</th>
      <th>XMPP error type</th>
      <th>Legacy error code</th>
    </tr>
    <tr>
      <td>&lt;bad-request/&gt;</td>
      <td>modify</td>
      <td>400</td>
    </tr>
    <tr>
      <td>&lt;conflict/&gt;</td>
      <td>cancel</td>
      <td>409</td>
    </tr>
    <tr>
      <td>&lt;feature-not-implemented/&gt;</td>
      <td>cancel</td>
      <td>501</td>
    </tr>
    <tr>
      <td>&lt;forbidden/&gt;</td>
      <td>auth</td>
      <td>403</td>
    </tr>
    <tr>
      <td>&lt;gone/&gt;</td>
      <td>modify</td>
      <td>302 (permanent)</td>
    </tr>
    <tr>
      <td>&lt;internal-server-error/&gt;</td>
      <td>wait</td>
      <td>500</td>
    </tr>
    <tr>
      <td>&lt;item-not-found/&gt;</td>
      <td>cancel</td>
      <td>404</td>
    </tr>
    <tr>
      <td>&lt;jid-malformed/&gt;</td>
      <td>modify</td>
      <td>400</td>
    </tr>
    <tr>
      <td>&lt;not-acceptable/&gt;</td>
      <td>modify</td>
      <td>406</td>
    </tr>
    <tr>
      <td>&lt;not-allowed/&gt;</td>
      <td>cancel</td>
      <td>405</td>
    </tr>
    <tr>
      <td>&lt;not-authorized/&gt;</td>
      <td>auth</td>
      <td>401</td>
    </tr>
    <tr>
      <td>&lt;payment-required/&gt;</td>
      <td>auth</td>
      <td>402</td>
    </tr>
    <tr>
      <td>&lt;recipient-unavailable/&gt;</td>
      <td>wait</td>
      <td>404</td>
    </tr>
    <tr>
      <td>&lt;redirect/&gt;</td>
      <td>modify</td>
      <td>302 (temporary)</td>
    </tr>
    <tr>
      <td>&lt;registration-required/&gt;</td>
      <td>auth</td>
      <td>407</td>
    </tr>
    <tr>
      <td>&lt;remote-server-not-found/&gt;</td>
      <td>cancel</td>
      <td>404</td>
    </tr>
    <tr>
      <td>&lt;remote-server-timeout/&gt;</td>
      <td>wait</td>
      <td>504</td>
    </tr>
    <tr>
      <td>&lt;resource-constraint/&gt;</td>
      <td>wait</td>
      <td>500</td>
    </tr>
    <tr>
      <td>&lt;service-unavailable/&gt;</td>
      <td>cancel</td>
      <td>503</td>
    </tr>
    <tr>
      <td>&lt;subscription-required/&gt;</td>
      <td>auth</td>
      <td>407</td>
    </tr>
    <tr>
      <td>&lt;undefined-condition/&gt;</td>
      <td>[any]</td>
      <td>500</td>
    </tr>
    <tr>
      <td>&lt;unexpected-request/&gt;</td>
      <td>wait</td>
      <td>400</td>
    </tr>
  </table>
</section1>

<section1 topic='Implementing Legacy Protocols'>
  <p>Implementors of legacy protocols should use the appropriate XMPP-style error alongside a legacy error code as specified in the following table:</p>

  <table caption='Mapping of legacy error codes to XMPP-style errors'>
    <tr>
      <th>Legacy error code</th>
      <th>Meaning</th>
      <th>XMPP error condition</th>
      <th>XMPP error type</th>
    </tr>
    <tr>
      <td>302</td>
      <td>Redirect</td>
      <td>&lt;redirect/&gt; (temporary) or &lt;gone/&gt; (permanent)</td>
      <td>modify</td>
    </tr>
    <tr>
      <td>400</td>
      <td>Bad Request</td>
      <td>&lt;bad-request/&gt;
        <note>See also the &lt;jid-malformed/&gt; and &lt;unexpected-request/&gt; stanza errors.</note>
      </td>
      <td>modify</td>
    </tr>
    <tr>
      <td>401</td>
      <td>Not Authorized</td>
      <td>&lt;not-authorized/&gt;
        <note>See also the &lt;not-authorized/&gt; stream error.</note>
      </td>
      <td>auth</td>
    </tr>
    <tr>
      <td>402</td>
      <td>Payment Required</td>
      <td>&lt;payment-required/&gt;</td>
      <td>auth</td>
    </tr>
    <tr>
      <td>403</td>
      <td>Forbidden</td>
      <td>&lt;forbidden/&gt;</td>
      <td>auth</td>
    </tr>
    <tr>
      <td>404</td>
      <td>Not Found</td>
      <td>&lt;item-not-found/&gt;
        <note>See also the &lt;remote-server-not-found/&gt; stanza error.</note>
      </td>
      <td>cancel</td>
    </tr>
    <tr>
      <td>405</td>
      <td>Not Allowed</td>
      <td>&lt;not-allowed/&gt;</td>
      <td>cancel</td>
    </tr>
    <tr>
      <td>406</td>
      <td>Not Acceptable</td>
      <td>&lt;not-acceptable/&gt;
        <note>See also the &lt;unexpected-request/&gt; stanza error.</note>
      </td>
      <td>modify</td>
    </tr>
    <tr>
      <td>407</td>
      <td>Registration Required</td>
      <td>&lt;registration-required/&gt;</td>
      <td>auth</td>
    </tr>
    <tr>
      <td>408</td>
      <td>Request Timeout</td>
      <td>&lt;remote-server-timeout/&gt;</td>
      <td>wait</td>
    </tr>
    <tr>
      <td>409</td>
      <td>Conflict</td>
      <td>&lt;conflict/&gt;</td>
      <td>cancel</td>
    </tr>
    <tr>
      <td>500</td>
      <td>Internal Server Error</td>
      <td>&lt;internal-server-error/&gt;
        <note>See also the &lt;undefined-condition/&gt; stanza error.</note>
      </td>
      <td>wait</td>
    </tr>
    <tr>
      <td>501</td>
      <td>Not Implemented</td>
      <td>&lt;feature-not-implemented/&gt;</td>
      <td>cancel</td>
    </tr>
    <tr>
      <td>502</td>
      <td>Remote Server Error</td>
      <td>&lt;service-unavailable/&gt;</td>
      <td>wait</td>
    </tr>
    <tr>
      <td>503</td>
      <td>Service Unavailable</td>
      <td>&lt;service-unavailable/&gt;</td>
      <td>cancel</td>
    </tr>
    <tr>
      <td>504</td>
      <td>Remote Server Timeout</td>
      <td>&lt;remote-server-timeout/&gt;</td>
      <td>wait</td>
    </tr>
    <tr>
      <td>510</td>
      <td>Disconnected</td>
      <td>&lt;service-unavailable/&gt;</td>
      <td>cancel</td>
    </tr>
  </table>
</section1>
<section1 topic='Conclusion'>
  <p>Mapping legacy error codes to XMPP-style errors is an inexact science, and there are likely to be inconsistencies in some places. However, it is the authors' belief that the mapping presented in this document will be adequate for the majority of cases, and will help smooth the migration to XMPP-compliant implementations.</p>
</section1>
</xep>
