From f6148d46a029f60aab93c8a0a93bf817706e9307 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Mon, 27 May 2024 11:13:10 +0530 Subject: [PATCH] Change detail field name --- ballerina/http_client_endpoint.bal | 22 +++++++++++----------- ballerina/http_errors.bal | 4 ++-- ballerina/http_response.bal | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ballerina/http_client_endpoint.bal b/ballerina/http_client_endpoint.bal index 557d7d2dd8..be9323b916 100644 --- a/ballerina/http_client_endpoint.bal +++ b/ballerina/http_client_endpoint.bal @@ -680,37 +680,37 @@ isolated function createResponseError(int statusCode, string reasonPhrase, map headers, anydata body = ()) returns ClientError { if 100 <= statusCode && statusCode <= 399 { - return error StatusCodeResponseBindingError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = false); + return error StatusCodeResponseBindingError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = false); } else if 400 <= statusCode && statusCode <= 499 { - return error StatusCodeBindingClientRequestError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = false); + return error StatusCodeBindingClientRequestError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = false); } else { - return error StatusCodeBindingRemoteServerError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = false); + return error StatusCodeBindingRemoteServerError(reasonPhrase, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = false); } } -isolated function createStatusCodeResponseDataBindingError("header"|"mediaType"|"payload"|"generic" errorType, boolean fromDefaultStatusCodeResponse, +isolated function createStatusCodeResponseDataBindingError("header"|"mediaType"|"payload"|"generic" errorType, boolean fromDefaultStatusCodeMapping, int statusCode, string reasonPhrase, map headers, anydata body = (), error? cause = ()) returns ClientError { match (errorType) { "header" => { if cause is HeaderValidationClientError { - return error HeaderValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error HeaderValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } - return error HeaderBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error HeaderBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } "mediaType" => { if cause is MediaTypeValidationClientError { - return error MediaTypeValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error MediaTypeValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } - return error MediaTypeBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error MediaTypeBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } "payload" => { if cause is PayloadValidationClientError { - return error PayloadValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error PayloadValidationStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } - return error PayloadBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error PayloadBindingStatusCodeClientError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } _ => { - return error StatusCodeResponseBindingError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeResponse = fromDefaultStatusCodeResponse); + return error StatusCodeResponseBindingError(reasonPhrase, cause, statusCode = statusCode, headers = headers, body = body, fromDefaultStatusCodeMapping = fromDefaultStatusCodeMapping); } } } diff --git a/ballerina/http_errors.bal b/ballerina/http_errors.bal index 6b50a22fe4..9377c1e175 100644 --- a/ballerina/http_errors.bal +++ b/ballerina/http_errors.bal @@ -29,10 +29,10 @@ public type Detail record { # Represents the details of an HTTP status code binding client error. # -# + fromDefaultStatusCodeResponse - Indicates whether the error orginates from default status code response mapping +# + fromDefaultStatusCodeMapping - Indicates whether the error orginates from default status code response mapping public type StatusCodeBindingErrorDetail record { *Detail; - boolean fromDefaultStatusCodeResponse; + boolean fromDefaultStatusCodeMapping; }; # Represents the details of the `LoadBalanceActionError`. diff --git a/ballerina/http_response.bal b/ballerina/http_response.bal index 815f87cd94..755e97b785 100644 --- a/ballerina/http_response.bal +++ b/ballerina/http_response.bal @@ -542,11 +542,11 @@ public class Response { isolated function buildStatusCodeResponse(typedesc? payloadType, typedesc statusCodeResType, boolean requireValidation, Status status, map headers, string? mediaType, - boolean fromDefaultStatusCodeResponse) returns StatusCodeResponse|ClientError { + boolean fromDefaultStatusCodeMapping) returns StatusCodeResponse|ClientError { if payloadType !is () { anydata|ClientError payload = self.performDataBinding(payloadType, requireValidation); if payload is ClientError { - return self.getStatusCodeResponseDataBindingError(payload.message(), fromDefaultStatusCodeResponse, "payload", payload); + return self.getStatusCodeResponseDataBindingError(payload.message(), fromDefaultStatusCodeMapping, "payload", payload); } return externBuildStatusCodeResponse(statusCodeResType, status, headers, payload, mediaType); } else { @@ -577,19 +577,19 @@ public class Response { } } - isolated function getStatusCodeResponseDataBindingError(string reasonPhrase, boolean fromDefaultStatusCodeResponse, + isolated function getStatusCodeResponseDataBindingError(string reasonPhrase, boolean fromDefaultStatusCodeMapping, "header"|"mediaType"|"payload"|"generic" errorType, error? cause) returns ClientError { map headers = getHeaders(self); anydata|error payload = getPayload(self); int statusCode = self.statusCode; if payload is error { if payload is NoContentError { - return createStatusCodeResponseDataBindingError(errorType, fromDefaultStatusCodeResponse, statusCode, reasonPhrase, headers, cause = cause); + return createStatusCodeResponseDataBindingError(errorType, fromDefaultStatusCodeMapping, statusCode, reasonPhrase, headers, cause = cause); } return error PayloadBindingClientError("http:StatusCodeBindingError creation failed: " + statusCode.toString() + " response payload extraction failed", payload); } else { - return createStatusCodeResponseDataBindingError(errorType, fromDefaultStatusCodeResponse, statusCode, reasonPhrase, headers, payload, cause); + return createStatusCodeResponseDataBindingError(errorType, fromDefaultStatusCodeMapping, statusCode, reasonPhrase, headers, payload, cause); } } }