Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_p_exception_8j_source.html

Full commit
<!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">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_exception_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:30 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: Foundation/CPException.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>Foundation/CPException.j</h1><a href="_c_p_exception_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * CPException.j</span>
<a name="l00003"></a>00003 <span class="comment"> * Foundation</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created by Francisco Tolmasky.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2008, 280 North, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00016"></a>00016 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPCoder.j&quot;</span>
<a name="l00024"></a>00024 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPObject.j&quot;</span>
<a name="l00025"></a>00025 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPString.j&quot;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 
<a name="l00028"></a><a class="code" href="_c_p_exception_8j.html#a6fa23775ddcbf086beab6aebeea123c3">00028</a> <a class="code" href="_c_p_exception_8j.html#a6fa23775ddcbf086beab6aebeea123c3">CPInvalidArgumentException</a>          = <span class="stringliteral">&quot;CPInvalidArgumentException&quot;</span>;
<a name="l00029"></a><a class="code" href="_c_p_exception_8j.html#aa22e47259ba202d50bf0efdf350c78df">00029</a> <a class="code" href="_c_p_exception_8j.html#aa22e47259ba202d50bf0efdf350c78df">CPUnsupportedMethodException</a>        = <span class="stringliteral">&quot;CPUnsupportedMethodException&quot;</span>;
<a name="l00030"></a><a class="code" href="_c_p_exception_8j.html#a8150488b853bf45c9b6aeb699acf0f33">00030</a> <a class="code" href="_c_p_exception_8j.html#a8150488b853bf45c9b6aeb699acf0f33">CPRangeException</a>                    = <span class="stringliteral">&quot;CPRangeException&quot;</span>;
<a name="l00031"></a><a class="code" href="_c_p_exception_8j.html#aef6598bfe3855334c5a867d55a8816a8">00031</a> <a class="code" href="_c_p_exception_8j.html#aef6598bfe3855334c5a867d55a8816a8">CPInternalInconsistencyException</a>    = <span class="stringliteral">&quot;CPInternalInconsistencyException&quot;</span>;
<a name="l00032"></a>00032 
<a name="l00047"></a><a class="code" href="class_c_p_exception.html">00047</a> <span class="keyword">@implementation </span><a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> : <a class="code" href="class_c_p_object.html" title="The root class from which most classes are subclassed.">CPObject</a>
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049     <span class="keywordtype">id</span>          _userInfo;
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <span class="comment">/*</span>
<a name="l00053"></a>00053 <span class="comment">    @ignore</span>
<a name="l00054"></a>00054 <span class="comment">*/</span>
<a name="l00055"></a><a class="code" href="class_c_p_exception.html#a7da95c8951bfbad4b9550a4092e23003">00055</a> + (id)alloc
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     <span class="keywordflow">return</span> <span class="keyword">new</span> Error();
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00065"></a><a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">00065</a> + (void)raise:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aName reason:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aReason
<a name="l00066"></a>00066 {
<a name="l00067"></a>00067     [[<span class="keyword">self</span> <a class="code" href="class_c_p_exception.html#a44c9e2d9ffa44471351ac8086093f542">exceptionWithName</a>:aName <a class="code" href="class_c_p_exception.html#a44c9e2d9ffa44471351ac8086093f542">reason</a>:aReason <a class="code" href="class_c_p_exception.html#a44c9e2d9ffa44471351ac8086093f542">userInfo</a>:nil] <a class="code" href="class_c_p_exception.html#a1428cc4e84f1d200dea624a85d6c9336">raise</a>];
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 
<a name="l00077"></a><a class="code" href="class_c_p_exception.html#a44c9e2d9ffa44471351ac8086093f542">00077</a> + (<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a>)exceptionWithName:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aName reason:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aReason userInfo:(<a class="code" href="class_c_p_dictionary.html" title="A mutable key-value pair collection.">CPDictionary</a>)aUserInfo
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079     <span class="keywordflow">return</span> [[<span class="keyword">self</span> <a class="code" href="class_c_p_exception.html#a7da95c8951bfbad4b9550a4092e23003">alloc</a>] <a class="code" href="class_c_p_exception.html#a556f18ad723ce3f34d320f2f394d720e">initWithName</a>:aName <a class="code" href="class_c_p_exception.html#a556f18ad723ce3f34d320f2f394d720e">reason</a>:aReason <a class="code" href="class_c_p_exception.html#a556f18ad723ce3f34d320f2f394d720e">userInfo</a>:aUserInfo];
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 
<a name="l00089"></a><a class="code" href="class_c_p_exception.html#a556f18ad723ce3f34d320f2f394d720e">00089</a> - (id)initWithName:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aName reason:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aReason userInfo:(<a class="code" href="class_c_p_dictionary.html" title="A mutable key-value pair collection.">CPDictionary</a>)aUserInfo
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00092"></a>00092 
<a name="l00093"></a>00093     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00094"></a>00094     {
<a name="l00095"></a>00095         name = aName;
<a name="l00096"></a>00096         message = aReason;
<a name="l00097"></a>00097         _userInfo = aUserInfo;
<a name="l00098"></a>00098     }
<a name="l00099"></a>00099     
<a name="l00100"></a>00100     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00106"></a><a class="code" href="class_c_p_exception.html#a06a61739c4a38ed44ef2506c52c6a2d0">00106</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)name
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108     <span class="keywordflow">return</span> name;
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00114"></a><a class="code" href="class_c_p_exception.html#a3b5a2a3dd133a21c6863d4b79ffabd04">00114</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)reason
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116     <span class="keywordflow">return</span> message;
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00122"></a><a class="code" href="class_c_p_exception.html#a81c441e5cf29613a7731718da9df3c8f">00122</a> - (<a class="code" href="class_c_p_dictionary.html" title="A mutable key-value pair collection.">CPDictionary</a>)userInfo
<a name="l00123"></a>00123 {
<a name="l00124"></a>00124     <span class="keywordflow">return</span> _userInfo;
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00130"></a><a class="code" href="class_c_p_exception.html#a750feb80da51185523c64e333c5cc7f0">00130</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)description
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132     <span class="keywordflow">return</span> message;
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134 
<a name="l00138"></a><a class="code" href="class_c_p_exception.html#a1428cc4e84f1d200dea624a85d6c9336">00138</a> - (void)raise
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140     <span class="keywordflow">throw</span> <span class="keyword">self</span>;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143 <span class="keyword">@end</span>
<a name="l00144"></a>00144 
<a name="l00145"></a>00145 <span class="keyword">@implementation </span><a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> (CPCopying)
<a name="l00146"></a>00146 
<a name="l00147"></a><a class="code" href="class_c_p_exception.html#a4d22c3bf8f65e3cc731f0855fab766f5">00147</a> - (id)<a class="code" href="class_c_p_exception.html#a4d22c3bf8f65e3cc731f0855fab766f5">copy</a>
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149     <span class="keywordflow">return</span> [[<span class="keyword">self</span> class] exceptionWithName:name reason:message userInfo:_userInfo];
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 <span class="keyword">@end</span>
<a name="l00153"></a>00153 
<a name="l00154"></a><a class="code" href="_c_p_exception_8j.html#ad7326ecf74b379d0ddb68e3d67cdacb9">00154</a> var <a class="code" href="_c_p_exception_8j.html#ad7326ecf74b379d0ddb68e3d67cdacb9">CPExceptionNameKey</a> = <span class="stringliteral">&quot;CPExceptionNameKey&quot;</span>,
<a name="l00155"></a><a class="code" href="_c_p_exception_8j.html#a37323f567f3c156f3834388b0eeb31ee">00155</a>     <a class="code" href="_c_p_exception_8j.html#a37323f567f3c156f3834388b0eeb31ee">CPExceptionReasonKey</a> = <span class="stringliteral">&quot;CPExceptionReasonKey&quot;</span>,
<a name="l00156"></a><a class="code" href="_c_p_exception_8j.html#a782368aef183fd8a4e7e746612a4a135">00156</a>     <a class="code" href="_c_p_exception_8j.html#a782368aef183fd8a4e7e746612a4a135">CPExceptionUserInfoKey</a> = <span class="stringliteral">&quot;CPExceptionUserInfoKey&quot;</span>;
<a name="l00157"></a>00157 
<a name="l00158"></a>00158 <span class="keyword">@implementation </span><a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> (CPCoding)
<a name="l00159"></a>00159 
<a name="l00165"></a><a class="code" href="class_c_p_exception.html#af45c39a952bb3ff7d06bbaa07757af1d">00165</a> - (id)initWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00168"></a>00168     
<a name="l00169"></a>00169     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00170"></a>00170     {
<a name="l00171"></a>00171         <a class="code" href="class_c_p_exception.html#a06a61739c4a38ed44ef2506c52c6a2d0">name</a> = [aCoder decodeObjectForKey:CPExceptionNameKey];
<a name="l00172"></a>00172         message = [aCoder decodeObjectForKey:CPExceptionReasonKey];
<a name="l00173"></a>00173         _userInfo = [aCoder decodeObjectForKey:CPExceptionUserInfoKey];
<a name="l00174"></a>00174     }
<a name="l00175"></a>00175     
<a name="l00176"></a>00176     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00183"></a><a class="code" href="class_c_p_exception.html#a6672dd68bf2c48367a51987180340927">00183</a> - (void)encodeWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l00184"></a>00184 {
<a name="l00185"></a>00185     [aCoder encodeObject:name forKey:CPExceptionNameKey];
<a name="l00186"></a>00186     [aCoder encodeObject:message forKey:CPExceptionReasonKey];
<a name="l00187"></a>00187     [aCoder encodeObject:_userInfo forKey:CPExceptionUserInfoKey];
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 
<a name="l00190"></a>00190 <span class="keyword">@end</span>
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 <span class="comment">// toll-free bridge Error to CPException</span>
<a name="l00193"></a>00193 <span class="comment">// [CPException alloc] uses an objj_exception, which is a subclass of Error</span>
<a name="l00194"></a><a class="code" href="_c_p_exception_8j.html#ae78e5d3e6c4d816e0bca45db991f1873">00194</a> Error.prototype.isa = <a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a>;
<a name="l00195"></a>00195 Error.prototype._userInfo = NULL;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> initialize];
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 function _CPRaiseInvalidAbstractInvocation(anObject, aSelector)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201     [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPInvalidArgumentException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:@&quot;*** -&quot; + sel_getName(aSelector) + @&quot; cannot be sent to an abstract object of class &quot; + [anObject className] + @&quot;: Create a concrete instance!&quot;];
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 function _CPReportLenientDeprecation(<span class="comment">/*Class*/</span> aClass, <span class="comment">/*SEL*/</span> oldSelector, <span class="comment">/*SEL*/</span> newSelector)
<a name="l00205"></a>00205 {
<a name="l00206"></a>00206     CPLog.warn(<span class="stringliteral">&quot;[&quot;</span> + <a class="code" href="_c_p_obj_j_runtime_8j.html#a49e200efd01d55599d5876d32dc5bfdb">CPStringFromClass</a>(aClass) + <span class="stringliteral">&quot; &quot;</span> + <a class="code" href="_c_p_obj_j_runtime_8j.html#aae150bb96566872e6ddb65964b6af330">CPStringFromSelector</a>(oldSelector) + <span class="stringliteral">&quot;] is deprecated, using &quot;</span> + <a class="code" href="_c_p_obj_j_runtime_8j.html#aae150bb96566872e6ddb65964b6af330">CPStringFromSelector</a>(newSelector) + <span class="stringliteral">&quot; instead.&quot;</span>);
<a name="l00207"></a>00207 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:56 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_exception_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:30 GMT -->
</html>