Skip to content

Commit

Permalink
Better panic message (#117)
Browse files Browse the repository at this point in the history
* Improve panic message when calling unloaded function

* Bump version
  • Loading branch information
KyleMayes authored Oct 1, 2020
1 parent 3377ff2 commit ddd3af5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.0.1] - 2020-10-01

### Changed
- Improved panic error message when calling an unloaded function

## [1.0.0] - 2020-07-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "clang-sys"
authors = ["Kyle Mayes <kyle@mayeses.com>"]

version = "1.0.0"
version = "1.0.1"

readme = "README.md"
license = "Apache-2.0"
Expand Down
10 changes: 6 additions & 4 deletions src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ macro_rules! link {
$(#[doc=$doc] #[cfg($cfg)])*
pub unsafe fn $name($($pname: $pty), *) $(-> $ret)* {
let f = with_library(|l| {
match l.functions.$name {
Some(f) => f,
_ => panic!(concat!("function not loaded: ", stringify!($name))),
}
l.functions.$name.expect(concat!(
"`libclang` function not loaded: `",
stringify!($name),
"`. This crate requires that `libclang` 3.9 or later be installed on your ",
"system. For more information on how to accomplish this, see here: ",
"https://rust-lang.github.io/rust-bindgen/requirements.html#installing-clang-39"))
}).expect("a `libclang` shared library is not loaded on this thread");
f($($pname), *)
}
Expand Down

0 comments on commit ddd3af5

Please sign in to comment.