rust-throw
rust-throw copied to clipboard
the trait `std::convert::From<&str>` is not implemented for `builders::java::throw::Error<&str>`
Hello I am trying to compile my code and I get the following error:
error[E0277]: the trait bound `builders::java::throw::Error<&str>: std::convert::From<&str>` is not satisfied
--> src/commands.rs:94:9
|
94 | throw_new!("Failure on create CloudState namespace");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `builders::java::throw::Error<&str>`
|
= note: required because of the requirements on the impl of `std::convert::Into<builders::java::throw::Error<&str>>` for `&str`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the trait bound `builders::java::throw::Error<&str>: std::convert::From<&str>` is not satisfied
My code:
fn create_namespace(namespace: String) -> Result<(), throw::Error<&'static str>> {
println!("Creating CloudState namespace...");
if let result = Command::new("kubectl")
.arg("create")
.arg("namespace")
.arg(namespace)
.spawn()
.is_ok() {
Ok(());
};
throw_new!("Failure on create CloudState namespace");
}
What should I do to get around this error?
Have you imported throw::Result by any chance?
I think this error is from you using throw::Result<(), throw::Error<&'static str>>, which expands to std::result::Result<(), throw::Error<throw::Error<&'static str>>>.
If that's the case, then I'd recommend either removing the throw::Result import, or using throw::Result<(), &'static str> instead.