-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Errors are inconsistent #2
Comments
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixpkgs-architecture-team-conclusion-and-prospective/41020/8 |
Going to do some work on this. If there's already someone working on this, please let me know. :) |
Awesome, feel free to! Nobody else is working on this :D |
So we talked about how it would be nice to just have a context type available to use for formatting the error types into strings in After pulling all the data out of all the
One goal of consistent errors seems to be to reduce this list so that more errors enum types are using similar context. And then we could do something like this: #[derive(Clone)]
pub struct NixpkgsProblem {
package_name: String,
file: RelativePathBuf,
line: usize,
// ...
kind: NixpkgsProblemKind
}
#[derive(Clone)]
pub enum NixpkgsProblemKind {
ShardNonDir,
InvalidShardName,
PackageNonDir,
CaseSensitiveDuplicate,
// ...
} I think if we tried to break up the current What are your thoughts? I probably need to so some research into common approaches to dealing with problems like this. Perhaps there's an |
Ping @philiptaron :) |
Check out the One example is this where all the returned errors have the same context. |
Actually, seems easier to just nest the struct into NixpkgsProblems like this and that way we would never need to downcast an anyhow error to get back well-typed context (used for testing etc). |
Regarding this one, the error becomes more obvious by having tests use
Note how the second error uses |
This pull request does not change the single-line vs multi-line style or any of the error messages. The goal here is to reduce code duplication. A lot of the NixpkgsProblem enum variants had common fields more or less due to the context of where the error originated. I grouped these similar problems into structs which contains the common fields and a kind enum to differentiate between the different types of problems. Work related to: #2
pkgs/by-name
errors are inconsistent
See the nixpkgs_problem.rs file. There's some different ways of construct error messages in there:
pkgs/by-name
errors, minor fixes and improvements nixpkgs#290743)EmptyArgument
), some are relative to the expression file (e.g.WrongCallPackagePath
, usingcreate_path_expr
). Ideally the latter should be used in all cases for more accurate errorsUndefinedAttr
has bothrelative_package_file
andpackage_name
, even though the former can be computed from the latter usingstructure::relative_file_for_package
, which e.g.EmptyArgument
does.These should be more consistent overall.
The text was updated successfully, but these errors were encountered: