You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
First of all, it seems that the order of the blocks in error_chain! { } matters (placing foreign_links after errors made it break). This feels different from the general top-level declarations in Rust so I was surprised. Can the macro be made flexible about the order of the declarations?
Secondly, and more importantly, I'm still unable to get it work :( I have code like this:
pub mod errors {
error_chain! {
foreign_links {
diesel::result::Error, DieselError;
}
errors {
NoSuchUser(email: String) {
description("No such user exists")
display("No user with e-mail address {} exists.", email)
}
EmailAddressTooLong {
description("E-mail address too long")
display("A valid e-mail address can be 254 characters at maximum.")
}
AuthError {
description("Can't authenticate user")
display("Username (= e-mail) or password doesn't match.")
}
}
}
}
use errors::*;
The foreign links section breaks:
error[E0433]: failed to resolve. Use of undeclared type or module `diesel::result`
--> src/lib.rs:29:13
|
29 | diesel::result::Error, DieselError;
| ^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `diesel::result`
<error_chain macros>:119:1: 124:37 note: in this expansion of error_chain! (defined in <error_chain macros>)
<error_chain macros>:133:1: 138:37 note: in this expansion of error_chain! (defined in <error_chain macros>)
src/lib.rs:27:5: 61:6 note: in this expansion of error_chain! (defined in <error_chain macros>)
But I have extern crate diesel; in place, so fully qualified paths starting with diesel should work, right? And trying to address the error message with use diesel::result; or use diesel::result::Error; doesn't help. What to do?
The text was updated successfully, but these errors were encountered:
Can the macro be made flexible about the order of the declarations?
I suspect it can, but it would need to be done by a more expert macrologist than I. Here's an issue #41.
But I have extern crate diesel; in place, so fully qualified paths starting with diesel should work, right? And trying to address the error message with use diesel::result; or use diesel::result::Error; doesn't help. What to do?
These paths will be resolved in the scope of the errors mod you have defined, but the extern crate diesel import only brings the diesel name into the top level of the crate; so either prefixing that path with ::, as in ::diesel::result::Error, or adding use diesel to the inside of the mod errors declaration should fix the resolution error.
First of all, it seems that the order of the blocks in error_chain! { } matters (placing foreign_links after errors made it break). This feels different from the general top-level declarations in Rust so I was surprised. Can the macro be made flexible about the order of the declarations?
Secondly, and more importantly, I'm still unable to get it work :( I have code like this:
The foreign links section breaks:
But I have
extern crate diesel;
in place, so fully qualified paths starting withdiesel
should work, right? And trying to address the error message withuse diesel::result;
oruse diesel::result::Error;
doesn't help. What to do?The text was updated successfully, but these errors were encountered: