ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Invalid error message for xml parsing in xml data module #6890

Closed SasinduDilshara closed 2 months ago

SasinduDilshara commented 2 months ago
import ballerina/data.xmldata;
import ballerina/io;

string s = string `
    <A xmlns:ns1="example1.com" xmlns:ns2="example2.com">
        <ns1:port>1</ns1:port>
        <ns2:port>1</ns2:port>
    </A>
`;

type A record {|
    B[] port;
|};

@xmldata:Namespace {
    prefix: "ns1",
    uri: "example1.com"
}
type B record {|
    string \#content; 
|};

public function main() returns error? {
    A rec = check xmldata:parseString(s);
    io:println(rec);
}

For above code, the output is following error message.

error: failed to parse xml: class io.ballerina.runtime.internal.types.BTypeReferenceType cannot be cast to class io.ballerina.runtime.api.types.RecordType (io.ballerina.runtime.internal.types.BTypeReferenceType and io.ballerina.runtime.api.types.RecordType are in unnamed module of loader 'app')

This error message should be improved without exposing the internal details

github-actions[bot] commented 2 months ago

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.