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

parse_file cannot return the expected error message. #236

Closed
zong-zhe opened this issue Oct 12, 2022 · 0 comments
Closed

parse_file cannot return the expected error message. #236

zong-zhe opened this issue Oct 12, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@zong-zhe
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

// source code in 'parser/src/lib.rs'
pub fn parse_file(filename: &str, code: Option<String>) -> Result<ast::Module, String> {
    create_session_globals_then(move || {
        let src = if let Some(s) = code {
            s
        } else {
            // the read file failed error message can not return.
            std::fs::read_to_string(filename).unwrap()
        };
....
}

2. What did you expect to see? (Required)

// do not use unwrap() and return the error message.
std::fs::read_to_string(filename).unwrap()

3. What did you see instead (Required)

It will panic, instead of return error message.

4. What is your KusionStack components version? (Required)

kclvm version is 0.4.3; checksum: e07ed7af0d9bd1e86a3131714e4bd20c

@zong-zhe zong-zhe added the bug Something isn't working label Oct 12, 2022
@zong-zhe zong-zhe added this to the v0.4.4 Release milestone Oct 12, 2022
@zong-zhe zong-zhe self-assigned this Oct 12, 2022
zong-zhe added a commit that referenced this issue Oct 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
#237)

Fix(kclvm-parser): return loading file failed error message from method `parse_file`.

use `match` replace `unwrap`.

issue #236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant