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

add more detail to errors #113

Merged
merged 14 commits into from
Jul 22, 2020
Merged

Conversation

jeremyandrews
Copy link
Member

@jeremyandrews jeremyandrews commented Jul 22, 2020

The goal of this PR is to make errors more rich, allowing application developers the option of what they want to display. In our examples, main() returns the errors so they are simply displayed.

  • enriched GooseError::InvalidHost, for example:

    $ cargo run --example drupal_loadtest -- --host=foo
        Finished dev [unoptimized + debuginfo] target(s) in 0.08s
         Running `target/debug/examples/drupal_loadtest --host=foo`
    Error: InvalidHost { host: "foo", detail: Some("Failure parsing host specified with --host"), parse_error: RelativeUrlWithoutBase }
    
  • enriched GooseError::FeatureNotEnabled, for example:

    $ cargo run --example drupal_loadtest -- --worker
        Finished dev [unoptimized + debuginfo] target(s) in 0.08s
         Running `target/debug/examples/drupal_loadtest --worker`
    Error: FeatureNotEnabled { feature: "gaggle", detail: Some("goose must be recompiled with `--features gaggle` to start in worker mode") }
    
  • enriched GooseError::InvalidWaitTime, for example:

         Running `target/debug/examples/drupal_loadtest`
    Error: InvalidWaitTime { min_wait: 5, max_wait: 1, detail: Some("min_wait can not be larger than max_wait") }
    
    
  • enriched GooseError::InvalidWeight, for example:

        Running `target/debug/examples/drupal_loadtest`
   Error: InvalidWeight { weight: 0, detail: Some("weight of 0 not allowed") }
  • enriched GooseError::NoTaskSets

         Running `target/debug/examples/drupal_loadtest`
    Error: NoTaskSets { detail: Some("no task sets defined") }
    
  • enriched GooseError::InvalidOption

    $ cargo run --example drupal_loadtest -- --host https://127.0.0.1/ --expect-workers=10
        Finished dev [unoptimized + debuginfo] target(s) in 0.08s
         Running `target/debug/examples/drupal_loadtest --host 'https://127.0.0.1/' --expect-workers=10`
    Error: InvalidOption { option: "--expect-workers", value: "10", detail: Some("--expect-workers is only available when running in manager mode") }
    

src/goose.rs Show resolved Hide resolved
src/goose.rs Outdated Show resolved Hide resolved
src/goose.rs Show resolved Hide resolved
src/goose.rs Outdated Show resolved Hide resolved
@jeremyandrews jeremyandrews force-pushed the errors branch 2 times, most recently from 2ff16af to d7ff47b Compare July 22, 2020 10:51
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@jeremyandrews jeremyandrews changed the title [WIP] add more detail to errors add more detail to errors Jul 22, 2020
@jeremyandrews jeremyandrews requested a review from LionsAd July 22, 2020 14:17
Copy link
Collaborator

@LionsAd LionsAd left a comment

Choose a reason for hiding this comment

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

RTBM - 0.9.0 is ready now

@jeremyandrews jeremyandrews merged commit a0de29b into tag1consulting:master Jul 22, 2020
@jeremyandrews jeremyandrews deleted the errors branch July 23, 2020 05:40
impl fmt::Display for GooseTaskError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self, f)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jeremyandrews This will create an infinite loop as per rust-lang/rust#74892.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It only works right now as we use the Debug and not the Display output for errors when returning from main.

Copy link
Member Author

Choose a reason for hiding this comment

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

see #128

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