Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class {{apiName}}Create{{resourceConstant}} : {{resourceConstant}}
return JsonConvert.DeserializeObject<{{apiName}}Create{{resourceConstant}}>(json);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
public static string ToJson(object model) {
try {
return JsonConvert.SerializeObject(model);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class {{apiName}}Fetch{{resourceConstant}} : {{resourceConstant}}
return JsonConvert.DeserializeObject<{{apiName}}Fetch{{resourceConstant}}>(json);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
public static string ToJson(object model) {
try {
return JsonConvert.SerializeObject(model);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class {{apiName}}Patch{{resourceConstant}} : {{resourceConstant}}
return JsonConvert.DeserializeObject<{{apiName}}Patch{{resourceConstant}}>(json);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
public static string ToJson(object model) {
try {
return JsonConvert.SerializeObject(model);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public class {{apiName}}Read{{resourceConstant}} : {{resourceConstant}}
return JsonConvert.DeserializeObject<{{apiName}}Read{{resourceConstant}}>(json);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going the route of creating only 1 exception class and merging the exception fields?

Copy link
Copy Markdown
Contributor Author

@sbansla sbansla Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I created different exception, creating one exception would create confusion to the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't here be then #isApiV1 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, but this exception should also be part of normal files, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadResponse.mustache is only applicable to v1.0 api standards.
Lets take an example of Message API, So Currently response is kept under Message class. But for v1.x apis, I am creating different classes for each operation, example: MessageReadResponse, MessageFetchResponse etc.
ReadResponse.mustache is used in generating MessageReadResponse.

Thats is why only ApiStandardException exists in here.
PR in twilio-csharp repo: twilio/twilio-csharp#814

}
}
public static string ToJson(object model) {
try {
return JsonConvert.SerializeObject(model);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class {{apiName}}Update{{resourceConstant}} : {{resourceConstant}}
return JsonConvert.DeserializeObject<{{apiName}}Update{{resourceConstant}}>(json);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
public static string ToJson(object model) {
try {
return JsonConvert.SerializeObject(model);
}
catch (JsonException e) {
throw new ApiException(e.Message, e);
throw new ApiStandardException(e.Message, e);
}
}
}