Changes between Initial Version and Version 1 of FAQs/WhyAreThereErrorsInTheColdFusionDebug

Show
Ignore:
Timestamp:
02/17/10 22:33:58 (16 years ago)
Author:
DanWilson (IP: 65.190.16.149)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQs/WhyAreThereErrorsInTheColdFusionDebug

    v1 v1  
     1Some developers look at the Exceptions section of the ColdFusion debugging and get a little nervous... "What do all these errors mean? Is my application broken?" 
     2 
     3Normally, when I see errors, they bother me too. However, in the case of the 
     4errors you see in the ColdFusion debugging coming from Model Glue and 
     5from ColdSpring, the errors are not indicative of any problem, rather a 
     6decision to an alternative code path.  
     7 
     8If you do not have an ORM configured, you'll see an error show up in the exceptions section. This doesn't mean your application is broken, unless you expected to use an ORM. The exception is thrown and caught so the framework can continue processing. Want an example? 
     9 
     10Here is the code that generates the error you see about ORM: 
     11 
     12{{{ 
     13 
     14<cftry> 
     15<cfset svc = mg.getBean("ormService") /> 
     16 <cfset adapter = mg.getBean("ormAdapter") /> 
     17 <cfset mg.setOrmService(svc) /> 
     18 <cfset mg.setOrmAdapter(adapter) /> 
     19 <cfcatch type="coldspring.NoSuchBeanDefinitionException"> 
     20 <!--- No bean, no ORM.  ---> 
     21</cfcatch> 
     22</cftry> 
     23 <cfif not isObject(getOrmAdapter())> 
     24<cfset arguments.event.addTraceStatement("ORM", "No ORM adapter is 
     25configured.  You will not be able to scaffold or use generic database 
     26messages.") /> 
     27 </cfif> 
     28 
     29}}} 
     30 
     31Now we could have written this code to be more aware of what was in 
     32ColdSpring, so we'd know whether or not there was in fact a configured ORM 
     33adapter. But that would have required making Model Glue a lot more aware of 
     34ColdSpring than we wanted. We would also have had to add a lot more checks 
     35and processing inside Model Glue for this purpose and it just didn't make 
     36any sense to do it that way. 
     37 
     38So, the logical way to handle it was to directly ask ColdSpring for the 
     39bean: 
     40 
     41{{{ 
     42 
     43<cfset svc = mg.getBean("ormService") /> 
     44<cfset adapter = mg.getBean("ormAdapter") /> 
     45 
     46}}} 
     47 
     48And let ColdSpring try to work out whether it had such a configuration and 
     49whether the bean could be created completely. ColdSpring throws an error if 
     50it doesn't work out, which we catch here: 
     51 
     52{{{ 
     53 
     54<cfcatch type="coldspring.NoSuchBeanDefinitionException"> 
     55<!--- No bean, no ORM.  ---> 
     56 </cfcatch> 
     57 
     58}}} 
     59 
     60So you see, these errors are really two different applications communicating 
     61to make decisions.