# Fail earlier?

**URL:** <https://community.thinkgeo.com/t/fail-earlier/298>\
**Category:** WinForms\
**Created:** [March 23, 2009, 5:14pm UTC](https://community.thinkgeo.com/t/fail-earlier/298 "2009-03-23T17:14:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kimberly](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kimberly](https://community.thinkgeo.com/u/Kimberly)\
**Post date:** [March 23, 2009, 5:14pm UTC](https://community.thinkgeo.com/t/fail-earlier/298/1 "2009-03-23T17:14:08Z")

</div>

I&nbsp;have&nbsp;a&nbsp;question&nbsp;about&nbsp;your&nbsp;exception&nbsp;model.&nbsp;I'm&nbsp;fairly&nbsp;new&nbsp;to&nbsp;your&nbsp;software&nbsp;so&nbsp;this&nbsp;might&nbsp;be&nbsp;more&nbsp;important&nbsp;to&nbsp;me&nbsp;than&nbsp;to&nbsp;most.&nbsp;There&nbsp;have&nbsp;been&nbsp;times&nbsp;when&nbsp;I've&nbsp;done&nbsp;something&nbsp;wrong&nbsp;(usually&nbsp;it's&nbsp;when&nbsp;I've&nbsp;refactored&nbsp;something),&nbsp;but&nbsp;rather&nbsp;than&nbsp;the&nbsp;ThinkGeo&nbsp;software&nbsp;telling&nbsp;what&nbsp;I've&nbsp;done&nbsp;wrong,&nbsp;the&nbsp;error&nbsp;happens&nbsp;after&nbsp;all&nbsp;my&nbsp;code&nbsp;has&nbsp;executed&nbsp;and&nbsp;gets&nbsp;caught&nbsp;in&nbsp;mscorlib.&nbsp;Certainly,&nbsp;the&nbsp;error&nbsp;has&nbsp;been&nbsp;mine,&nbsp;but&nbsp;it&nbsp;seems&nbsp;that&nbsp;the&nbsp;errors&nbsp;I'm&nbsp;causing&nbsp;would&nbsp;be&nbsp;fairly&nbsp;simple&nbsp;for&nbsp;the&nbsp;map&nbsp;software&nbsp;to&nbsp;check&nbsp;rather&nbsp;than&nbsp;just&nbsp;letting&nbsp;it&nbsp;propogate.&nbsp;And&nbsp;then&nbsp;by&nbsp;the&nbsp;time&nbsp;it&nbsp;gets&nbsp;to&nbsp;mscorlib,&nbsp;I&nbsp;get&nbsp;some&nbsp;fairly&nbsp;meaningless&nbsp;error&nbsp;like&nbsp;"The&nbsp;supplied&nbsp;key&nbsp;isn't&nbsp;in&nbsp;the&nbsp;dictionary."&nbsp;or&nbsp;"Input&nbsp;was&nbsp;not&nbsp;in&nbsp;the&nbsp;correct&nbsp;format.".

The&nbsp;times&nbsp;that&nbsp;I've&nbsp;noticed&nbsp;this&nbsp;that&nbsp;I&nbsp;can&nbsp;remember&nbsp;include:

Having&nbsp;an&nbsp;incorrect&nbsp;column&nbsp;name&nbsp;on&nbsp;the&nbsp;feature&nbsp;(same&nbsp;as&nbsp;not&nbsp;having&nbsp;the&nbsp;column,&nbsp;I&nbsp;guess)

Not&nbsp;realizing&nbsp;that&nbsp;a&nbsp;string&nbsp;I&nbsp;used&nbsp;was&nbsp;going&nbsp;to&nbsp;be&nbsp;converted&nbsp;to&nbsp;a&nbsp;number.&nbsp;(I&nbsp;can't&nbsp;recall&nbsp;exactly&nbsp;what&nbsp;caused&nbsp;that&nbsp;one,&nbsp;but&nbsp;my&nbsp;co-worker&nbsp;and&nbsp;I&nbsp;each&nbsp;individually&nbsp;raised&nbsp;it.)

I&nbsp;put&nbsp;a&nbsp;0&nbsp;in&nbsp;for&nbsp;an&nbsp;int&nbsp;as&nbsp;the&nbsp;final&nbsp;value&nbsp;in&nbsp;a&nbsp;constructor&nbsp;(sorry&nbsp;I&nbsp;don't&nbsp;remember&nbsp;where&nbsp;that&nbsp;was&nbsp;and&nbsp;I&nbsp;must&nbsp;have&nbsp;refactored&nbsp;that&nbsp;code&nbsp;away).&nbsp;It&nbsp;turned&nbsp;out&nbsp;that&nbsp;the&nbsp;range&nbsp;started&nbsp;at&nbsp;1,&nbsp;but&nbsp;again&nbsp;I&nbsp;got&nbsp;some&nbsp;weird&nbsp;windows&nbsp;error.

I&nbsp;think&nbsp;there&nbsp;was&nbsp;at&nbsp;least&nbsp;one&nbsp;other&nbsp;case,&nbsp;but&nbsp;I&nbsp;don't&nbsp;recall&nbsp;it.&nbsp;In&nbsp;any&nbsp;case,&nbsp;I'm&nbsp;wondering&nbsp;why&nbsp;you&nbsp;don't&nbsp;fail&nbsp;earlier?&nbsp;I'm&nbsp;trying&nbsp;to&nbsp;make&nbsp;sure&nbsp;I&nbsp;add&nbsp;unit&nbsp;tests&nbsp;to&nbsp;my&nbsp;code&nbsp;when&nbsp;I&nbsp;run&nbsp;into&nbsp;this,&nbsp;but&nbsp;from&nbsp;the&nbsp;point&nbsp;of&nbsp;view&nbsp;of&nbsp;learning,&nbsp;it&nbsp;would&nbsp;be&nbsp;rather&nbsp;nice&nbsp;to&nbsp;get&nbsp;an&nbsp;error&nbsp;telling&nbsp;me&nbsp;that&nbsp;the&nbsp;column&nbsp;I&nbsp;referenced&nbsp;doesn't&nbsp;exist.&nbsp;As&nbsp;I&nbsp;mentioned,&nbsp;it's&nbsp;usually&nbsp;when&nbsp;I&nbsp;refactor&nbsp;something&nbsp;and&nbsp;I&nbsp;have&nbsp;a&nbsp;habit&nbsp;of&nbsp;thinking&nbsp;my&nbsp;refactored&nbsp;code&nbsp;should&nbsp;work&nbsp;exactly&nbsp;the&nbsp;same&nbsp;as&nbsp;it&nbsp;did&nbsp;before.&nbsp;:-D

Thank&nbsp;you!

Kimberly

&nbsp;

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [March 24, 2009, 4:56am UTC](https://community.thinkgeo.com/t/fail-earlier/298/2 "2009-03-24T04:56:45Z")

</div>

Kimberly,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;very&nbsp;much&nbsp;for&nbsp;your&nbsp;suggestions,&nbsp;that’s&nbsp;really&nbsp;good.&nbsp;  
&nbsp;&nbsp;  
&nbsp;In&nbsp;fact,&nbsp;almost&nbsp;all&nbsp;the&nbsp;public&nbsp;methods&nbsp;(public&nbsp;and&nbsp;protected)&nbsp;have&nbsp;the&nbsp;parameters&nbsp;checking&nbsp;at&nbsp;the&nbsp;entry&nbsp;point.&nbsp;If&nbsp;you&nbsp;have&nbsp;chance&nbsp;to&nbsp;see&nbsp;our&nbsp;source&nbsp;code,&nbsp;you&nbsp;will&nbsp;find&nbsp;the&nbsp;parameter&nbsp;checking&nbsp;all&nbsp;over&nbsp;the&nbsp;place.&nbsp;&nbsp;From&nbsp;what&nbsp;you&nbsp;said,&nbsp;seems&nbsp;our&nbsp;checking&nbsp;is&nbsp;still&nbsp;not&nbsp;enough&nbsp;though.&nbsp;For&nbsp;example,&nbsp;if&nbsp;input&nbsp;0&nbsp;to&nbsp;a&nbsp;1-based&nbsp;integer,&nbsp;it&nbsp;should&nbsp;throw&nbsp;an&nbsp;exception,&nbsp;we&nbsp;might&nbsp;overlook&nbsp;that.&nbsp;Thanks&nbsp;for&nbsp;pointing&nbsp;that&nbsp;out&nbsp;and&nbsp;we&nbsp;will&nbsp;keep&nbsp;on&nbsp;improving&nbsp;the&nbsp;exception&nbsp;system&nbsp;in&nbsp;the&nbsp;future.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;again!&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben

---

<div class="post-metadata">

**Author:** ![Kimberly](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kimberly](https://community.thinkgeo.com/u/Kimberly)\
**Post date:** [March 30, 2009, 3:56pm UTC](https://community.thinkgeo.com/t/fail-earlier/298/3 "2009-03-30T15:56:02Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;the&nbsp;response&nbsp;Ben.&nbsp;I&nbsp;imagine&nbsp;it&nbsp;would&nbsp;be&nbsp;pretty&nbsp;difficult&nbsp;to&nbsp;come&nbsp;up&nbsp;with&nbsp;all&nbsp;possible&nbsp;errors&nbsp;we're&nbsp;going&nbsp;to&nbsp;generate.

Kimberly

&nbsp;

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [April 1, 2009, 9:41am UTC](https://community.thinkgeo.com/t/fail-earlier/298/4 "2009-04-01T09:41:18Z")

</div>

That’s&nbsp;difficult&nbsp;to&nbsp;cover&nbsp;all&nbsp;the&nbsp;places&nbsp;but&nbsp;your&nbsp;feedback&nbsp;will&nbsp;always&nbsp;help&nbsp;us&nbsp;make&nbsp;it&nbsp;better.&nbsp;Thanks&nbsp;for&nbsp;pointing&nbsp;this&nbsp;out,&nbsp;Kimberly.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [April 1, 2009, 3:44pm UTC](https://community.thinkgeo.com/t/fail-earlier/298/5 "2009-04-01T15:44:16Z")

</div>

If&nbsp;we&nbsp;can&nbsp;tell&nbsp;you&nbsp;of&nbsp;checking&nbsp;that&nbsp;we&nbsp;would&nbsp;like&nbsp;to&nbsp;see&nbsp;performed...&nbsp;&nbsp;I'm&nbsp;writing&nbsp;custom&nbsp;layers&nbsp;and&nbsp;features&nbsp;sources.&nbsp;&nbsp;&nbsp;I've&nbsp;had&nbsp;some&nbsp;experiences&nbsp;in&nbsp;getting&nbsp;layers&nbsp;added&nbsp;to&nbsp;a&nbsp;map&nbsp;w/o&nbsp;a&nbsp;feature&nbsp;source.&nbsp;&nbsp;&nbsp;&nbsp;That&nbsp;creates&nbsp;a&nbsp;stack&nbsp;trace&nbsp;of&nbsp;1347&nbsp;levels&nbsp;(maybe&nbsp;a&nbsp;slight&nbsp;exageration),&nbsp;and&nbsp;ends&nbsp;with&nbsp;a&nbsp;null&nbsp;reference&nbsp;exception&nbsp;error&nbsp;:)

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [April 3, 2009, 1:01am UTC](https://community.thinkgeo.com/t/fail-earlier/298/6 "2009-04-03T01:01:31Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;1347&nbsp;levels,&nbsp;&nbsp;that’s&nbsp;something&nbsp;:).&nbsp;&nbsp;We&nbsp;will&nbsp;gradually&nbsp;and&nbsp;surely&nbsp;add&nbsp;all&nbsp;the&nbsp;checking&nbsp;we&nbsp;can&nbsp;think&nbsp;of&nbsp;and&nbsp;I&nbsp;hope&nbsp;in&nbsp;the&nbsp;future&nbsp;release,&nbsp;you&nbsp;will&nbsp;not&nbsp;meet&nbsp;any&nbsp;issues&nbsp;like&nbsp;that.&nbsp;  
&nbsp;&nbsp;  
&nbsp;By&nbsp;the&nbsp;way,&nbsp;can&nbsp;you&nbsp;let&nbsp;me&nbsp;know&nbsp;how&nbsp;to&nbsp;recreate&nbsp;the&nbsp;1347&nbsp;stack&nbsp;trace&nbsp;issue?&nbsp;I&nbsp;think&nbsp;it&nbsp;must&nbsp;use&nbsp;recursive&nbsp;or&nbsp;something&nbsp;but&nbsp;I’m&nbsp;not&nbsp;sure&nbsp;where&nbsp;it&nbsp;is.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben
