diff --git a/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs b/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs index beafcbce3..0f205aaca 100644 --- a/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs +++ b/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs @@ -293,7 +293,7 @@ private static Response ProcessResponse(Response response) { restException = RestException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow null check below to handle */ } + catch (JsonException) { /* Allow null check below to handle */ } if (restException != null) { @@ -312,7 +312,7 @@ private static Response ProcessResponse(Response response) { restApiStandardException = RestApiStandardException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow fallback to legacy format */ } + catch (JsonException) { /* Allow fallback to legacy format */ } if (restApiStandardException != null) { diff --git a/src/Twilio/Clients/NoAuth/TwilioNoAuthRestClient.cs b/src/Twilio/Clients/NoAuth/TwilioNoAuthRestClient.cs index 6f6162a5d..f26343027 100644 --- a/src/Twilio/Clients/NoAuth/TwilioNoAuthRestClient.cs +++ b/src/Twilio/Clients/NoAuth/TwilioNoAuthRestClient.cs @@ -171,7 +171,7 @@ private static Response ProcessResponse(Response response) { restException = RestException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow null check below to handle */ } + catch (JsonException) { /* Allow null check below to handle */ } if (restException != null) @@ -192,7 +192,7 @@ private static Response ProcessResponse(Response response) { restApiStandardException = RestApiStandardException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow fallback to legacy format */ } + catch (JsonException) { /* Allow fallback to legacy format */ } // Check if it's a valid RFC 9457 response (has 'type' field) if (restApiStandardException != null) diff --git a/src/Twilio/Clients/TwilioRestClient.cs b/src/Twilio/Clients/TwilioRestClient.cs index 64fa7f6be..1d2e88861 100644 --- a/src/Twilio/Clients/TwilioRestClient.cs +++ b/src/Twilio/Clients/TwilioRestClient.cs @@ -232,7 +232,7 @@ private static Response ProcessResponse(Response response) { restException = RestException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow null check below to handle */ } + catch (JsonException) { /* Allow null check below to handle */ } if (restException != null) { @@ -245,14 +245,14 @@ private static Response ProcessResponse(Response response) ); } - + // Try to deserialize as RFC 9457 format first (RestApiStandardException) RestApiStandardException restApiStandardException = null; try { restApiStandardException = RestApiStandardException.FromJson(response.Content); } - catch (JsonReaderException) { /* Allow fallback to legacy format */ } + catch (JsonException) { /* Allow fallback to legacy format */ } // Check if it's a valid RFC 9457 response (has 'type' field) if (restApiStandardException != null)