Skip to content

Commit 28d4513

Browse files
PhantomGrazzlermilkshakeuk
authored andcommitted
Updated data type generator so that DataTypeException is thrown instead of a general exception for component accessor methods.
1 parent aa0924c commit 28d4513

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/NHapi.SourceGeneration/Generators/DataTypeGenerator.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ private static string MakeComposite(
460460
source.Append("\t///<param name=\"index\">The index item to get (zero based)</param>\r\n");
461461
source.Append("\t///<returns>The data component (as a type) at the requested number (ordinal)</returns>\r\n");
462462
source.Append("\t///</summary>\r\n");
463-
source.Append("\tpublic IType this[int index] { \r\n\r\n");
464-
source.Append("get{\r\n");
463+
source.Append("\tpublic IType this[int index] { \r\n");
464+
source.Append("\tget{\r\n");
465465
source.Append("\t\ttry { \r\n");
466466
source.Append("\t\t\treturn this.data[index]; \r\n");
467467
source.Append("\t\t} catch (System.ArgumentOutOfRangeException) { \r\n");
@@ -497,7 +497,7 @@ private static string MakeComposite(
497497
}
498498

499499
source.Append(" {\r\n");
500-
source.Append("get{\r\n");
500+
source.Append("\tget{\r\n");
501501
source.Append("\t ");
502502
source.Append(dtName);
503503
source.Append(" ret = null;\r\n");
@@ -510,16 +510,13 @@ private static string MakeComposite(
510510
source.Append("\t } catch (DataTypeException e) {\r\n");
511511
source.Append(
512512
"\t HapiLogFactory.GetHapiLog(this.GetType()).Error(\"Unexpected problem accessing known data type component - this is a bug.\", e);\r\n");
513-
source.Append("\t throw new System.Exception(\"An unexpected error occurred\",e);\r\n");
513+
source.Append("\t throw new DataTypeException(\"An unexpected error occurred\", e);\r\n");
514514
source.Append("\t }\r\n");
515515
source.Append("\t return ret;\r\n");
516-
source.Append("}\r\n\r\n");
516+
source.Append("\t}\r\n\r\n");
517517
source.Append("}\r\n");
518518
}
519519

520-
/*if (correspondingControlInterface != null) {
521-
source.append(Control.getImplementation(correspondingControlInterface, version));
522-
} */
523520
source.Append("}");
524521

525522
return source.ToString();

0 commit comments

Comments
 (0)