Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: on fail does not support having multiple error types #40377

Open
suleka96 opened this issue May 9, 2023 · 0 comments
Open

[Bug]: on fail does not support having multiple error types #40377

suleka96 opened this issue May 9, 2023 · 0 comments
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@suleka96
Copy link
Contributor

suleka96 commented May 9, 2023

Description

As of now, union support for on fail clause is not available, thus having multiple errors is not supported. The same issue is present in foreach as both traverse through the same resolving path.

Steps to Reproduce

type SampleErrorData record {|
    int code;
    string reason;
|};

type SampleError error<SampleErrorData>;

type SampleComplexErrorData record {|
    error cause;   
    int code;
    int[2] pos;
    record {string moreInfo;} infoDetails;
|};

type SampleComplexError error<SampleComplexErrorData>;

public function main() {
    boolean isPositiveState = false;
      do {
        if isPositiveState {
            fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20,  pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); 
        }
        fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition");
    } on fail var error(_, pos = [tr, ty]) {
            io:println(tr);
    }
}

This gives the below errors:

ERROR [test7.bal:(80:34,80:42)] invalid list binding pattern: expected an array or a tuple, but found 'ballerina/lang.value:0.0.0:Cloneable'
ERROR [test7.bal:(81:24,81:26)] undefined symbol 'tr'

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@suleka96 suleka96 added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant