<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">

<chapter>
  <header>
    <copyright>
      <year>1997</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.
    
      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.
    
    </legalnotice>

    <title>Appendix A: Mnesia Error Messages</title>
    <prepared>Claes Wikstr&ouml;m, Hans Nilsson and H&aring;kan Mattsson</prepared>
    <responsible>Bjarne D&auml;cker</responsible>
    <docno></docno>
    <approved>Bjarne D&auml;cker</approved>
    <checked>Bjarne D&auml;cker</checked>
    <date>96-11-20</date>
    <rev>B</rev>
    <file>Mnesia_App_A.xml</file>
  </header>
  <p>Whenever an operation returns an error in Mnesia, a description
    of the error is available. For example, the functions
    <c>mnesia:transaction(Fun)</c>, or <c>mnesia:create_table(N,L)</c>
    may return the tuple <c>{aborted, Reason}</c>, where <c>Reason</c>
    is a term describing the error.  The following function is used to
    retrieve more detailed information about the error:
    </p>
  <list type="bulleted">
    <item><c>mnesia:error_description(Error)</c></item>
  </list>

  <section>
    <title>Errors in Mnesia</title>
    <p>The following is a list of valid errors in Mnesia.</p>
    <list type="bulleted">
      <item><c>badarg</c>.  Bad or invalid argument, possibly bad type.
      </item>
      <item><c>no_transaction</c>. Operation not allowed outside transactions.
      </item>
      <item><c>combine_error</c>. Table options were illegally combined.
      </item>
      <item><c>bad_index</c>. Index already exists, or was out of bounds.
      </item>
      <item><c>already_exists</c>. Schema option to be activated is already on.
      </item>
      <item><c>index_exists</c>. Some operations cannot be performed on tables with an  index.
      </item>
      <item><c>no_exists</c>.; Tried to perform operation on non-existing (non-alive) item.
      </item>
      <item><c>system_limit</c>.; A system limit was exhausted.
      </item>
      <item><c>mnesia_down</c>. A transaction involves records on a
       remote  node which became unavailable before the transaction
       was completed. Record(s) are no longer available elsewhere in
       the network.</item>
      <item><c>not_a_db_node</c>. A node was mentioned which does not exist in the schema.</item>
      <item><c>bad_type</c>.; Bad type specified in argument.</item>
      <item><c>node_not_running</c>. Node is not running.</item>
      <item><c>truncated_binary_file</c>. Truncated binary in file.</item>
      <item><c>active</c>. Some delete operations require that all active records are removed.</item>
      <item><c>illegal</c>. Operation not supported on this record.</item>
    </list>
    <p>The following example illustrates a function which returns an error, and the method to retrieve more detailed error information.
      </p>
    <p>The function <c>mnesia:create_table(bar, [{attributes, 3.14}])</c> will return the tuple <c>{aborted,Reason}</c>, where <c>Reason</c> is the tuple 
      <c>{bad_type,bar,3.14000}</c>. 
      </p>
    <p>The function <c>mnesia:error_description(Reason)</c>, returns the term
      <c>{"Bad type on some provided arguments",bar,3.14000}</c> which is an error
      description suitable
      for display.</p>
  </section>
</chapter>