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

Issue #109 | Improving errors #184

Merged
merged 10 commits into from
Sep 23, 2022
Merged

Issue #109 | Improving errors #184

merged 10 commits into from
Sep 23, 2022

Conversation

MariaArtemis
Copy link
Contributor

@MariaArtemis MariaArtemis commented Sep 22, 2022

Tag #109

Alright, so this is the work I've done so far. It's not in a complete stage yet, and some more work needs to be done. I think I could finish whatever changes are needed tomorrow, but a solution needs to be found for one stark problem, and that it can be very hard to know exactly where and what broke when these happen, and I think we can fix that by:

  1. Enforce a "standard" error message. This could be something like "Function run() | src/run.rs | 'Failed to start up' "
  2. Add a String to each enum so that we can print out said string
  3. Use more error matching the like so we can solve errors on the spot than piping them up if we don't absolutely need to pipe them up.

Sidenote: I'm glad this project is using MIT. Maybe we can add a file called CONTRIBUTORS adding everyone's individual copyright license, but I digress, it's not important for me.

Also, the majority of files were edited, but the majority is just converting the new function. The majority of changes happened in main.rs and errors.rs.

There are failing tests but that can be fixed at the end, I'm guessing the majority of them is just not made for the new kinds of errors.

Adrian Berg added 2 commits September 22, 2022 16:52
A new error type has been created for the binary part of the tool,
and the project should compile and work. It works with printing out
the errors, and works just like any good old Rust error. There is
however one weak point, and that is debugging is hard with this method.
This should be solved before this is merged into main.
Copy link
Owner

@cnpryer cnpryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. It's quite nice. Good job! I'm in the middle of some unrelated work. So I'd like to come back and play with it. But so far this is looking great!

A couple quick changes I spotted can be resolved though.

.gitignore Outdated Show resolved Hide resolved
src/bin/huak/main.rs Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
Co-authored-by: Chris Pryer <[email protected]>
@MariaArtemis
Copy link
Contributor Author

Cheers.

I'll go through all of the requests tomorrow when I'm done with school.

src/bin/huak/main.rs Outdated Show resolved Hide resolved
@cnpryer
Copy link
Owner

cnpryer commented Sep 22, 2022

Cheers.

I'll go through all of the requests tomorrow when I'm done with school.

Take your time :)

I tried running it but couldn't. Looks like the ci-rust action is failing. Just a heads up.

@MariaArtemis
Copy link
Contributor Author

Thats odd. It runs fine for me. I'll have a look at that

@cnpryer
Copy link
Owner

cnpryer commented Sep 22, 2022

I just gh pr checkout 184 from master and it worked. Odd.

@MariaArtemis
Copy link
Contributor Author

Oh the CI fails cus some tests fail. Mentioned that in the original post. I'll be fixing those tmr

Co-authored-by: Chris Pryer <[email protected]>
@MariaArtemis
Copy link
Contributor Author

I got errands today but I'll do some work tonight. If you go back to original post, what do you think about improving these errors with more debug information?

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

I got errands today but I'll do some work tonight. If you go back to original post, what do you think about improving these errors with more debug information?

No prob. I appreciate the communication.

I'd say let's try to implement this in pieces. We can keep PRs smaller. So a follow up one can add debug info. This one we should just improve on the current error handling. I like what you have here, I just want us to clarify how we'll handle the logic I called out in my most recent comment.

So

Add a String to each enum so that we can print out said string

this I like. I just think we need something for when it's an error code/info from a process we're wrapping (like ruff's).

Use more error matching the like so we can solve errors on the spot than piping them up if we don't absolutely need to pipe them up.

this I also like. but we should approach it in pieces.

Copy link
Owner

@cnpryer cnpryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment specifically

src/huak/errors.rs Outdated Show resolved Hide resolved
@MariaArtemis
Copy link
Contributor Author

Thanks, I'll have a look at it.

@MariaArtemis
Copy link
Contributor Author

Oh the CI fails cus some tests fail. Mentioned that in the original post. I'll be fixing those tmr

I'm looking at the error and its giving me "No such file or directory (os error 2)" errors. I have no clue what this means, but I'll be digging through whats failing.

Adrian Berg added 2 commits September 23, 2022 23:41
and the option for Ruff, PyBlack and PyTest errors can be done. Fixed .gitignore too.
src/huak/errors.rs Outdated Show resolved Hide resolved
@MariaArtemis
Copy link
Contributor Author

Okay, it compiles and works now, and I (think) have implemented what you wanted changed. The only problem is the tests, which I don't even know my changes to the error type makes it fail, considering its an OS error?

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

I see cargo fmt --check is failing.

@MariaArtemis
Copy link
Contributor Author

I think I need to fix my IDE's pushing then, it should do cargo fmt before my commit but apparently not. Tests still fail.

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

If you're talking about pre-commit it's only running --check. You need to run cargo fmt. cargo clippy too.

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

More info on the checks at the bottom of this section.

@MariaArtemis
Copy link
Contributor Author

Yeah, was just me misunderstanding what "Reformat code" did in IntelliJ, but I'll remember to fmt now. The linter is not happy, but I don't know how to run that locally.

@MariaArtemis
Copy link
Contributor Author

However, after fixing what the linter complains about, the main problem is just tests. I still do not know what makes them fail, but the errors I get is this

---- ops::clean::tests::clean stdout ----
resource archive does not exist
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CliError { error: AnyHowError(No such file or directory (os error 2)) }', src/huak/utils/test_utils.rs:15:19

This happens on:

failures:
    env::venv::tests::from
    ops::clean::tests::clean
    ops::fmt::tests::fmt
    ops::install::tests::installs_dependenices
    ops::new::tests::creates_project
    ops::remove::tests::removes_dependencies
    project::tests::from

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

However, after fixing what the linter complains about, the main problem is just tests. I still do not know what makes them fail, but the errors I get is this...

heh. A great reason to welcome PRs like these 😅

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

I can try to help out in a bit if you need it. when we have better errors we'll have less trouble debugging something like this.

@MariaArtemis
Copy link
Contributor Author

Debugging help would be nice. I do not know how it doesn't fail on the current main branch, so SOMETHING has changed between current main and my dev branch. I'll be trying to fix this now.

@MariaArtemis
Copy link
Contributor Author

Could it be the tests themselves are faulty? It's erroring on the fact that there are no files, which doesn't have anything to do with my contribution. The only things I have changed myself is how errors are handled. Very weird error.

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

Could the tests be faulty

For sure. This entire project was started this month lol. I should be able to help out soon.

@MariaArtemis
Copy link
Contributor Author

MariaArtemis commented Sep 23, 2022

I've digged through the edited files and I see nothing that could change the behavior of functions. ¯\_(ツ)_/¯

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

What OS are you on?

@MariaArtemis
Copy link
Contributor Author

I'm running Pop!_OS 22.04.

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

with

env::venv::tests::from

failing I think it's something to do with the mock strategy for tests I think it's when it's attempting to create a .venv. but I'm unsure. we're you running the tests locally before?

@MariaArtemis
Copy link
Contributor Author

we're you running the tests locally before?

Not before opening the PR

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

Do you have the alias for python?

@MariaArtemis
Copy link
Contributor Author

I don't use aliases, so I'm not sure what you mean by this.

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

I'm wondering if it fails here. We should add a MssingPython error or something.

crate::utils::command::run_command("python", &args, from)?;

See #160

@MariaArtemis
Copy link
Contributor Author

Pushed this so the linter is happy. If the tests fail there, then idk

@cnpryer
Copy link
Owner

cnpryer commented Sep 23, 2022

If you use discord it might help to chat more there https://discord.gg/St3menxFZT

src/huak/env/venv.rs Outdated Show resolved Hide resolved
@cnpryer cnpryer merged commit 8a03059 into cnpryer:master Sep 23, 2022
@cnpryer cnpryer mentioned this pull request Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants