Git Product home page Git Product logo

Comments (9)

xffxff avatar xffxff commented on May 17, 2024 1

So I think we should go with the solution you suggested 🙂, What are your thoughts

Okay, I will implement this solution 🚀 🙂

from websurfx.

neon-mmd avatar neon-mmd commented on May 17, 2024

@xffxff as we had discussed this issue earlier, would you like to work on this issue?? 🙂

from websurfx.

xffxff avatar xffxff commented on May 17, 2024

Yes, I would be willing to work on this issue. @neon-mmd

from websurfx.

xffxff avatar xffxff commented on May 17, 2024

I have found that it is not possible to convert scraper::error::SelectorErrorKind to Report because Report requires the error to be Sync and Send. Unfortunately, scraper::error::SelectorErrorKind is not thread-safe, and therefore the following code is invalid:

let no_result: Selector = Selector::parse(".no-results").into_report()?;

from websurfx.

neon-mmd avatar neon-mmd commented on May 17, 2024

I have found that it is not possible to convert scraper::error::SelectorErrorKind to Report because Report requires the error to be Sync and Send. Unfortunately, scraper::error::SelectorErrorKind is not thread-safe, and therefore the following code is invalid:

let no_result: Selector = Selector::parse(".no-results").into_report()?;

This seems interesting 🙂, Is there any other way to fix this if possible ?? or any other possible solutions?? 🙂 .

from websurfx.

xffxff avatar xffxff commented on May 17, 2024

@neon-mmd I think one solution is to avoid converting scraper::error::SelectorErrorKind to Report. Instead, we can create a Report with UnexpectedError

let no_result: Selector = Selector::parse(".no-results")
    .map_err(|_| Report::new(EngineError::UnexpectedError))
    .attach_printable_lazy(|| format!("invalid CSS selector: {}", ".no-results"))?;

However, by doing this, we lose the information about the lower-level source of UnexpectedError, which in this case is scraper::error::SelectorErrorKind. This is not equivalent to our current implementation:

pub enum EngineErrorKind {
    RequestError(reqwest::Error),
    EmptyResultSet,
    UnexpectedError {
        message: String,
        source: Option<Box<dyn std::error::Error>>,
    },
}

from websurfx.

neon-mmd avatar neon-mmd commented on May 17, 2024

@neon-mmd I think one solution is to avoid converting scraper::error::SelectorErrorKind to Report. Instead, we can create a Report with UnexpectedError

let no_result: Selector = Selector::parse(".no-results")
    .map_err(|_| Report::new(EngineError::UnexpectedError))
    .attach_printable_lazy(|| format!("invalid CSS selector: {}", ".no-results"))?;

However, by doing this, we lose the information about the lower-level source of UnexpectedError, which in this case is scraper::error::SelectorErrorKind. This is not equivalent to our current implementation:

pub enum EngineErrorKind {
    RequestError(reqwest::Error),
    EmptyResultSet,
    UnexpectedError {
        message: String,
        source: Option<Box<dyn std::error::Error>>,
    },
}

I think maybe we could try using the std feature for error-stack, I feel it would solve the issue and if that doesn't work then we will go with this implementation you mentioned. what do you say @xffxff ?? 🙂

from websurfx.

xffxff avatar xffxff commented on May 17, 2024

I think maybe we could try using the std feature for error-stack, I feel it would solve the issue

@neon-mmd I think I have already used the std feature, as it is the default feature flag for error-stack.

from websurfx.

neon-mmd avatar neon-mmd commented on May 17, 2024

I think maybe we could try using the std feature for error-stack, I feel it would solve the issue

@neon-mmd I think I have already used the std feature, as it is the default feature flag for error-stack.

My bad 😄, I think I didn't read this part because the docs say it is built mostly on no-std and the features section mentioned the std feature explicitly, So now we have only one option to forth we would need to make tradeoff making the selector-error less informative while making others more informative and I think this tradeoff won't be that bad I feel because it would make most of the errors more informative than the current implementation which doesn't offer that much information on errors. So I think we should go with the solution you suggested 🙂, What are your thoughts @xffxff ??

from websurfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.