Skip to content

Commit d166edc

Browse files
committed
feat: result err to boxed for pass clippy
1 parent 7a8ca05 commit d166edc

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,14 @@ pub struct CompileResult {
468468
}
469469

470470
impl TryFrom<CompileResponse> for CompileResult {
471-
type Error = Exception;
471+
type Error = Box<Exception>;
472472

473473
fn try_from(response: CompileResponse) -> Result<Self> {
474474
let res = response.result.unwrap();
475475
match res {
476476
compile_response::Result::Success(success) => Ok(success.into()),
477477
compile_response::Result::Failure(failure) => {
478-
Err(Exception::from(failure))
478+
Err(Exception::from(failure).into())
479479
}
480480
}
481481
}

src/embedded.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ impl Embedded {
8383

8484
let host = Host::new(importer_registry, logger_registry);
8585
let conn = self.channel.connect(host)?;
86-
let response = conn.compile_request(request)?;
86+
let response = conn
87+
.compile_request(request)
88+
.map_err(|e| Box::new(e.into()))?;
8789
CompileResult::try_from(response)
8890
}
8991

@@ -171,7 +173,9 @@ impl Embedded {
171173

172174
let host = Host::new(importer_registry, logger_registry);
173175
let conn = self.channel.connect(host)?;
174-
let response = conn.compile_request(request)?;
176+
let response = conn
177+
.compile_request(request)
178+
.map_err(|e| Box::new(e.into()))?;
175179
CompileResult::try_from(response)
176180
}
177181

@@ -181,7 +185,7 @@ impl Embedded {
181185
let importer_registry = ImporterRegistry::default();
182186
let host = Host::new(importer_registry, logger_registry);
183187
let conn = self.channel.connect(host)?;
184-
let response = conn.version_request()?;
188+
let response = conn.version_request().map_err(|e| Box::new(e.into()))?;
185189
Ok(format!(
186190
"sass-embedded\t#{}",
187191
response.implementation_version

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
};
99

1010
/// An alias for [std::result::Result<T, Exception>].
11-
pub type Result<T> = std::result::Result<T, Exception>;
11+
pub type Result<T> = std::result::Result<T, Box<Exception>>;
1212

1313
/// An exception for this crate, thrown because a Sass compilation failed or `io::Error`.
1414
///

tests/importer_spec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ fn wraps_an_error_in_canonicalize() {
241241
_: &str,
242242
_: &ImporterOptions,
243243
) -> Result<Option<Url>> {
244-
Err(Exception::new("this import is bad actually"))
244+
Err(Exception::new("this import is bad actually").into())
245245
}
246246

247247
fn load(&self, _: &Url) -> Result<Option<ImporterResult>> {
@@ -275,7 +275,7 @@ fn wraps_an_error_in_load() {
275275
}
276276

277277
fn load(&self, _: &Url) -> Result<Option<ImporterResult>> {
278-
Err(Exception::new("this import is bad actually"))
278+
Err(Exception::new("this import is bad actually").into())
279279
}
280280
}
281281

@@ -305,7 +305,7 @@ fn avoids_importer_when_canonicalize_returns_nil() {
305305
}
306306

307307
fn load(&self, _: &Url) -> Result<Option<ImporterResult>> {
308-
Err(Exception::new("this import is bad actually"))
308+
Err(Exception::new("this import is bad actually").into())
309309
}
310310
}
311311

@@ -1006,7 +1006,7 @@ mod file_importer {
10061006
_: &str,
10071007
_: &ImporterOptions,
10081008
) -> Result<Option<Url>> {
1009-
Err(Exception::new("this import is bad actually"))
1009+
Err(Exception::new("this import is bad actually").into())
10101010
}
10111011
}
10121012

0 commit comments

Comments
 (0)