Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
use crate::types::ScriptErrorConstructorKind;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum ModuleLoadStage {
Fetch,
Compile,
Resolve,
Instantiate,
Evaluate,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ModuleLoadError {
stage: ModuleLoadStage,
message: String,
error_constructor: Option<ScriptErrorConstructorKind>,
top_level_module_load_failure: bool,
}
impl ModuleLoadError {
pub(crate) fn new(stage: ModuleLoadStage, message: impl Into<String>) -> Self {
Self {
stage,
message: message.into(),
error_constructor: None,
top_level_module_load_failure: false,
}
}
pub(crate) fn with_error_constructor(
mut self,
error_constructor: ScriptErrorConstructorKind,
) -> Self {
self.error_constructor = Some(error_constructor);
self
}
pub(crate) fn with_top_level_module_load_failure(mut self) -> Self {
self.top_level_module_load_failure = true;
self
}
pub(crate) fn stage(&self) -> ModuleLoadStage {
self.stage
}
pub(crate) fn message(&self) -> &str {
&self.message
}
pub(crate) fn error_constructor(&self) -> Option<ScriptErrorConstructorKind> {
self.error_constructor
}
pub(crate) fn is_top_level_module_load_failure(&self) -> bool {
self.top_level_module_load_failure
}
}