Skip to main content
Participant
April 3, 2009
Answered

cfcatch raise_application_error

  • April 3, 2009
  • 1 reply
  • 1094 views
Hello all,
I've defined a custom exception and message in a stored procedure and am attempting to display it to the user via the cfcatch object. The problem is that I'm unable to easily display the message since it doesn't appear to be easily referenced. For example, I have defined the message "This is an exception." but it is only available in cfcatch.detail and cfcatch.message is only a generic error. Is there a way to return this message without parsing?

Message: Error Executing Database Query.
NativeErrorCode: 20101
Detail: [Macromedia][Oracle JDBC Driver][Oracle]ORA-20101: This is an exception. ORA-06512: at "BLAH.BLAH", line 180 ORA-06512: at line 1
ExtendedInfo:
Type: Database
SQLState: HY000

Thanks!
This topic has been closed for replies.
Correct answer mmcarthey
I ended up creating a cffunction that accepts the cfcatch structure. Since the cfcatch structure contains the errorcode (cfcatch.NativeErrorCode) and the message (cfcatch.Detail) I just parsed for the string and returned the value. Once catch is that you have to duplicate the cfcatch struct before passing.

<!--- The range of allowed custom exception values returned from raise_application_error --->
<cfif cfcatch.NativeErrorCode gte 20000 AND cfcatch.NativeErrorCode lte 20999>
<cfoutput>
#ParseOracleError( duplicate(cfcatch) )#
</cfoutput>
</cfif>

Any questions, please ask.

1 reply

mmcartheyAuthorCorrect answer
Participant
April 3, 2009
I ended up creating a cffunction that accepts the cfcatch structure. Since the cfcatch structure contains the errorcode (cfcatch.NativeErrorCode) and the message (cfcatch.Detail) I just parsed for the string and returned the value. Once catch is that you have to duplicate the cfcatch struct before passing.

<!--- The range of allowed custom exception values returned from raise_application_error --->
<cfif cfcatch.NativeErrorCode gte 20000 AND cfcatch.NativeErrorCode lte 20999>
<cfoutput>
#ParseOracleError( duplicate(cfcatch) )#
</cfoutput>
</cfif>

Any questions, please ask.