-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: basic error support * Tweak
- Loading branch information
Showing
22 changed files
with
217 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use rolldown_error::BuildError; | ||
use smallvec::SmallVec; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct BatchedErrors(SmallVec<[BuildError; 1]>); | ||
|
||
impl BatchedErrors { | ||
pub fn with_error(err: BuildError) -> Self { | ||
Self(smallvec::smallvec![err]) | ||
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.0.is_empty() | ||
} | ||
|
||
pub fn push(&mut self, err: BuildError) { | ||
self.0.push(err); | ||
} | ||
|
||
/// Try to take the Err() of the given result and return Some(T) if it's Ok(T). | ||
pub fn take_err_from<T>(&mut self, res: Result<T, rolldown_error::BuildError>) -> Option<T> { | ||
match res { | ||
Ok(t) => Some(t), | ||
Err(err) => { | ||
self.push(err); | ||
None | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub type BatchedResult<T> = Result<T, BatchedErrors>; | ||
|
||
impl From<BuildError> for BatchedErrors { | ||
fn from(err: BuildError) -> Self { | ||
Self::with_error(err) | ||
} | ||
} | ||
|
||
impl From<BatchedErrors> for Vec<BuildError> { | ||
fn from(errs: BatchedErrors) -> Self { | ||
errs.0.into_vec() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod bundler; | ||
mod error; | ||
mod plugin; | ||
|
||
use std::sync::Arc; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.