From d1663ee520c58280274b962cc28286de43637f9e Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 23 Jun 2023 12:33:52 +0530 Subject: [PATCH 1/4] [Automated] Update native jar versions in toml files --- ballerina/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 6fcb2f4d..d31775a5 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,7 +5,7 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.7.0-20230619-175900-bb4e4544" +distribution-version = "2201.7.0-20230622-064700-4a2dc6dd" [[package]] org = "ballerina" From c2c687f22983f46bb09d1036e2c02e47e10c410a Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Wed, 28 Jun 2023 12:22:11 +0530 Subject: [PATCH 2/4] Add Util functions to improve usage of runtime.invokeMethodAsynchronously --- codecov.yml | 2 -- .../stdlib/persist/ErrorGenerator.java | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java diff --git a/codecov.yml b/codecov.yml index d87fb6b7..f60b970a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,5 +1,3 @@ -ignore: - - "ballerina/googlesheets_client.bal" coverage: precision: 2 round: down diff --git a/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java new file mode 100644 index 00000000..11a96585 --- /dev/null +++ b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java @@ -0,0 +1,29 @@ +package io.ballerina.stdlib.persist; + +import io.ballerina.runtime.api.creators.ErrorCreator; +import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.values.BError; +import io.ballerina.runtime.api.values.BMap; +import io.ballerina.runtime.api.values.BString; + +import static io.ballerina.stdlib.persist.Constants.ERROR; +import static io.ballerina.stdlib.persist.ModuleUtils.getModule; + +/** + * This class provides the error generator methods for persistence. + * + * @since 1.1.0 + */ +public class ErrorGenerator { + private static BError generatePersistError(BString message, BError cause, BMap details) { + return ErrorCreator.createError(getModule(), ERROR, message, cause, details); + } + + public static BError getBasicPersistError(String message) { + return generatePersistError(StringUtils.fromString(message), null, null); + } + + public static BError wrapError(BError error) { + return generatePersistError(error.getErrorMessage(), error.getCause(), null); + } +} From 0bab755b93aba7dbf0aff8408b36ddc4d75a097a Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Mon, 17 Jul 2023 11:27:37 +0530 Subject: [PATCH 3/4] Add private constructor to Error Generator --- .../main/java/io/ballerina/stdlib/persist/ErrorGenerator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java index 11a96585..972a565b 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java @@ -15,6 +15,9 @@ * @since 1.1.0 */ public class ErrorGenerator { + + private ErrorGenerator() { + } private static BError generatePersistError(BString message, BError cause, BMap details) { return ErrorCreator.createError(getModule(), ERROR, message, cause, details); } From fe83294a1026025e198b5b9cb90960ac1e36da4d Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Mon, 17 Jul 2023 17:12:09 +0530 Subject: [PATCH 4/4] Add license header --- .../stdlib/persist/ErrorGenerator.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java index ddb09475..f77a4171 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/ErrorGenerator.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package io.ballerina.stdlib.persist; import io.ballerina.runtime.api.creators.ErrorCreator;