Skip to content

Commit

Permalink
Merge pull request #54 from daneshk/main
Browse files Browse the repository at this point in the history
Fix the issue in showing the actual error message
  • Loading branch information
daneshk authored Oct 8, 2024
2 parents 88dad3c + 6baf582 commit 7f30765
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ This file contains all the notable changes done to the Ballerina protoc-tools pa
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2024-10-07

### Fixed

- [Fix the NPE when there is message field type of google.protobuf.Empty](https://github.com/ballerina-platform/ballerina-library/issues/7230)
- [Fix the issue in showing the actual error message](https://github.com/ballerina-platform/ballerina-library/issues/7238)


## [0.3.0] - 2024-06-27

### Fixed
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ researchgateReleaseVersion=2.8.0
testngVersion=7.6.1
jacocoVersion=0.8.10

stdlibGrpcVersion=1.11.1
stdlibIoVersion=1.6.0
stdlibTimeVersion=2.4.0
stdlibGrpcVersion=1.11.2
stdlibIoVersion=1.6.1
stdlibTimeVersion=2.5.0
stdlibUrlVersion=2.4.0

stdlibConstraintVersion=1.4.0
stdlibCryptoVersion=2.7.0
stdlibConstraintVersion=1.5.0
stdlibCryptoVersion=2.7.2
stdlibLogVersion=2.9.0
stdlibOsVersion=1.8.0
stdlibProtobufVersion=1.6.0
stdlibProtobufVersion=1.6.1
stdlibRandomVersion=1.5.0
stdlibTaskVersion=2.5.0

Expand All @@ -34,11 +34,11 @@ stdlibFileVersion=1.9.0
stdlibMimeVersion=2.9.0
stdlibUuidVersion=1.8.0

stdlibAuthVersion=2.11.0
stdlibJwtVersion=2.11.0
stdlibAuthVersion=2.11.2
stdlibJwtVersion=2.12.1
stdlibOAuth2Version=2.11.0

stdlibHttpVersion=2.11.0
stdlibHttpVersion=2.11.4

# Ballerinax Observer
observeVersion=1.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ private void generateBalFile(String protoPath) {
}
} catch (CodeGeneratorException e) {
String errorMessage = "An error occurred when generating the proto descriptor. " + e.getMessage();
LOG.error("An error occurred when generating the proto descriptor.", e);
outStream.println(errorMessage);
LOG.error("An error occurred when generating the proto descriptor.", e);
return;
}
if (root.getDescriptor().length == 0) {
String errorMsg = "An error occurred when generating the proto descriptor.";
LOG.error(errorMsg);
outStream.println(errorMsg);
LOG.error(errorMsg);
return;
}
LOG.debug("Successfully generated the root descriptor.");
Expand All @@ -292,8 +292,8 @@ private void generateBalFile(String protoPath) {
} catch (CodeGeneratorException e) {
String errorMessage =
"An error occurred when generating the dependent proto descriptor. " + e.getMessage();
LOG.error(errorMessage, e);
outStream.println(errorMessage);
LOG.error(errorMessage, e);
return;
}
LOG.debug("Successfully generated the dependent descriptor.");
Expand All @@ -316,10 +316,10 @@ private void generateBalFile(String protoPath) {
}
ballerinaFileBuilder.build(this.mode);
} catch (CodeBuilderException | CodeGeneratorException | IOException e) {
LOG.error("Error generating the Ballerina file.", e);
msg.append("Error generating the Ballerina file.").append(e.getMessage())
.append(BalGenerationConstants.NEW_LINE_CHARACTER);
outStream.println(msg);
LOG.error("Error generating the Ballerina file.", e);
return;
}
msg.append("Successfully generated the Ballerina file.").append(BalGenerationConstants.NEW_LINE_CHARACTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public static ArrayList<String> generateDescriptor(String command) throws CodeGe
" running the protoc executor. " + e.getMessage(), e);
}
if (process.exitValue() != 0) {
handleProcessExecutionErrors(process);
StringBuilder errMsg = new StringBuilder();
for (String line : output) {
errMsg.append(line).append(System.lineSeparator());
}
throw new CodeGeneratorException("Process exited with the following output: \n" + errMsg);
}
return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.testng.annotations.Test;

import static io.ballerina.protoc.tools.ToolingTestUtils.assertGeneratedDataTypeSourcesNegative;
import static io.ballerina.protoc.tools.ToolingTestUtils.assertGeneratedSources;

/**
Expand Down Expand Up @@ -103,4 +104,10 @@ public void testUnaryWithEmptyFieldMessage() {
"emptyFieldMessage_pb.bal", "testservice_service.bal",
"testservice_client.bal", "tool_test_unary_11");
}

@Test
public void testUnaryWithSchemaSyntaxErrors() {
assertGeneratedDataTypeSourcesNegative("unary", "schemaSyntaxErrors.proto",
"schemaSyntaxErrors_pb.bal", "tool_test_unary_12");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org).
*
* 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.
*/

syntax = "proto3";

package test;

service TestService {
rpc TestRPC(RequestMessage) returns (ResponseMessage);
}

enum TestEnum {
ENTRY_ONE = 0;
ENTRY_TWO = 1
}

message ComplexType {
uint32 foo = 1;
TestEnum bar = 2;
}

message OptionalComplexType {
oneof value {
ComplexType complex_value = 1;
// A field to represent `None`. It's usually left as an empty field.
Empty none = 2;
}
}

message OptionalString {
oneof value {
string name = 1;
// A field to represent `None`. It's usually left as an empty field.
Empty none = 2;
}
}

message RequestMessage {
repeated OptionalComplexType req;
}

message ResponseMessage {
repeated OptionalString resp = 1;
}

message Empty

0 comments on commit 7f30765

Please sign in to comment.