<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFTHROW</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="説明">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFTHROW</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">説明</span>
<p>
開発者指定の例外を返します。この例外は、cfcatch タグで次のいずれかの type 属性オプションを指定して検出できます。
</p>
<ul>

<li>type = &quot;custom_type&quot; </li>

<li>type = &quot;Application&quot; </li>

<li>type = &quot;Any&quot; </li>
</ul>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">カテゴリ</span>
<p>
例外処理タグ、フロー制御タグ
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</span><pre>&lt;cfthrow
   type = &quot;exception_type &quot;
   message = &quot;message&quot;
   detail = &quot;detail_description &quot;
   errorCode = &quot;error_code &quot;
   extendedInfo = &quot;additional_information&quot;
   object = &quot;java_except_object&quot;&gt;
</pre>  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</span><pre>&lt;cfthrow
   object = #object_name#&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">関連項目</span>
<p>
cferror、cfrethrow、cftry、onError、『ColdFusion MX 開発ガイド』の第14章の「エラーの処理」 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">ヒストリ</span>
<p>
ColdFusion&#160;MX: 返される例外が変更されました。このタグは、ColdFusion コンポーネントメソッドの例外を発生させます。
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">使用方法</span>
<p>
エラーを返すには、このタグを cftry ブロック内で使用します。cfcatch ブロックを使用すると、次のような付属情報にアクセスできます。 
</p>
<ul>

<li>メッセージ (cfcatch.message を使用した場合) </li>

<li>詳細 (cfcatch.detail を使用した場合) </li>

<li>エラーコード (cfcatch.errorcode を使用した場合) </li>
</ul>

<p>
さらに情報を取得するには、cfcatch.tagContext を使用してください。この配列には、タグスタック内でページ間のコントロールが切り替わる位置が示されます (例 : cfinclude、cfmodule)。
</p>

<p>
tagContext によって表示される情報を参照するには、ColdFusion MX Administrator の [デバッグ] ページで、[トレース情報] を選択します。
</p>

<p>
<b>object パラメータの使用&#160;</b>このタグを object パラメータと共に使用するには、まず有効な Java 例外クラスを指定する cfobject タグを使用する必要があります。たとえば、次の cfobject タグでは、例外クラス myException (これは Java で作成する必要があります) のオブジェクト obj を定義しています。
</p>
<pre>&lt;cfobject 
type=&quot;java&quot;
action=&quot;create&quot;
class=&quot;myException&quot; 
name=&quot;obj&quot;&gt;
</pre>
<p>
例外クラスにメッセージなどのパラメータを取るコンストラクタがある場合は、次のように特殊な init メソッドを使用してコンストラクタを呼び出すことができます。コンストラクタの属性を指定する必要がない場合は、この手順を省略できます。
</p>
<pre>&lt;cfset obj.init(&quot;この先に進む前に作業内容を保存してください&quot;)&gt;
</pre>
<p>
次に cfthrow ステートメントを使用して、次のように例外を返すことができます。 
</p>
<pre>&lt;cfthrow object=#obj#&gt;
</pre>
<p>
ColdFusion での Java オブジェクトの使用方法の詳細については、『ColdFusion MX 開発ガイド』の第37章の「CFML アプリケーションへの J2EE および Java 要素の統合」 を参照してください。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">例</span><pre>&lt;h3&gt;cfthrow の例&lt;/h3&gt;
&lt;!--- cftry ブロックを開きます。 ---&gt;
&lt;cftry&gt;
&lt;!--- エラーを返す条件を定義します。 ---&gt;
&lt;cfif NOT IsDefined(&quot;URL.myID&quot;)&gt;
   &lt;!--- エラーを返す ---&gt;
   &lt;cfthrow message = &quot;ID が定義されていません。&quot;&gt;
&lt;/cfif&gt;

&lt;!--- エラーを検出します。 ---&gt;
&lt;cfcatch type = &quot;application&quot;&gt;
&lt;!--- メッセージを表示します。 ---&gt;
   &lt;h3&gt;&lt;b&gt;エラーが発生しました&lt;/b&gt;&lt;/h3&gt;
&lt;cfoutput&gt;
   &lt;!--- アプリケーションサーバーからの診断フィードバック ---&gt;
  &lt;p&gt;#cfcatch.message#&lt;/p&gt;
   &lt;p&gt;タグスタックの内容は次のとおりです。&lt;/p&gt;
   &lt;cfloop 
      index = i
      from = 1 to = #ArrayLen(cfcatch.tagContext)#&gt;
          &lt;cfset sCurrent = #cfcatch.tagContext[i]#&gt;
             &lt;br&gt;#i# #sCurrent[&quot;ID&quot;]#
            (#sCurrent[&quot;LINE&quot;]#,#sCurrent[&quot;COLUMN&quot;]#)
            #sCurrent[&quot;TEMPLATE&quot;]#
   &lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;/cfcatch&gt;
&lt;/cftry&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">例</span>
<p>
次の例では、コンポーネントメソッドから例外を返す方法を示します。
</p>
<pre>&lt;cfcomponent&gt;
   &lt;cffunction name=&quot;getEmp&quot;&gt;
   &lt;cfargument name=&quot;lastName&quot; required=&quot;yes&quot;&gt;    
       &lt;cfquery name=&quot;empQuery&quot; datasource=&quot;cfdocexamples&quot; &gt;
          SELECT LASTNAME, FIRSTNAME, EMAIL
          FROM tblEmployees
         WHERE LASTNAME LIKE &#39;#arguments.lastName#&#39;
       &lt;/cfquery&gt;
       &lt;cfif empQuery.recordcount LT 1&gt;
          &lt;cfthrow type=&quot;noQueryResult&quot; 
            message=&quot;結果が見つかりません。やり直してください。&quot;&gt;
         &lt;cfelse&gt;
              &lt;cfreturn empQuery&gt;
        &lt;/cfif&gt;
   &lt;/cffunction&gt;
&lt;/cfcomponent&gt;
</pre>
<p>
この例の説明と、さらに詳しい情報については、『ColdFusion MX 開発ガイド』の第10章の「ColdFusion コンポーネントの作成と使用」 を参照してください。
</p>

         </td>
      </tr>
   </table>
   </div>
<div id="TYPE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">TYPE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "Application"

<ul>

<li>カスタムタイプ</li>

<li>Application</li>
</ul>

<p>他の定義済みのタイプは ColdFusion アプリケーションでは生成されないため、入力しないでください。Application を指定する場合は、cfcatch のタイプを指定する必要はありません。</p>

  </td>
  </tr>
  </table>
</div>
<div id="MESSAGE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">MESSAGE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>例外的なイベントを示すメッセージです。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="DETAIL">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DETAIL</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>イベントの説明です。ColdFusion では、エラー位置を説明に追加します。サーバーでは、エラーがコードで検出されない場合にこのパラメータを使用します。</p>

  </td>
  </tr>
  </table>
</div>
<div id="ERRORCODE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ERRORCODE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ユーザーが指定するカスタムエラーコードです。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="EXTENDEDINFO">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">EXTENDEDINFO</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ユーザーが指定するカスタムエラーコードです。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="OBJECT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">OBJECT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>cfobject タグの name 属性の値が必要です。</p>
<p>CFML タグからの Java 例外を返します。</p>
<p>この属性は、このタグのその他すべての属性とは独立しています。</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
