Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not throw general exceptions from generated data types #390

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/NHapi.SourceGeneration/Generators/DataTypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ private static string MakeComposite(
source.Append("\t///<param name=\"index\">The index item to get (zero based)</param>\r\n");
source.Append("\t///<returns>The data component (as a type) at the requested number (ordinal)</returns>\r\n");
source.Append("\t///</summary>\r\n");
source.Append("\tpublic IType this[int index] { \r\n\r\n");
source.Append("get{\r\n");
source.Append("\tpublic IType this[int index] { \r\n");
source.Append("\tget{\r\n");
source.Append("\t\ttry { \r\n");
source.Append("\t\t\treturn this.data[index]; \r\n");
source.Append("\t\t} catch (System.ArgumentOutOfRangeException) { \r\n");
Expand Down Expand Up @@ -497,7 +497,7 @@ private static string MakeComposite(
}

source.Append(" {\r\n");
source.Append("get{\r\n");
source.Append("\tget{\r\n");
source.Append("\t ");
source.Append(dtName);
source.Append(" ret = null;\r\n");
Expand All @@ -510,16 +510,13 @@ private static string MakeComposite(
source.Append("\t } catch (DataTypeException e) {\r\n");
source.Append(
"\t HapiLogFactory.GetHapiLog(this.GetType()).Error(\"Unexpected problem accessing known data type component - this is a bug.\", e);\r\n");
source.Append("\t throw new System.Exception(\"An unexpected error occurred\",e);\r\n");
source.Append("\t throw new DataTypeException(\"An unexpected error occurred\", e);\r\n");
source.Append("\t }\r\n");
source.Append("\t return ret;\r\n");
source.Append("}\r\n\r\n");
source.Append("\t}\r\n\r\n");
source.Append("}\r\n");
}

/*if (correspondingControlInterface != null) {
source.append(Control.getImplementation(correspondingControlInterface, version));
} */
source.Append("}");

return source.ToString();
Expand Down