Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ language: rust
rust:
- stable
- beta
- 1.25.0
- 1.36.0
script: |
cargo build --verbose &&
cargo test --verbose --all
matrix: # additional tests
include:
- rust: nightly
script: cargo test --all --features nightly
- rust: 1.29.1
- rust: 1.36.0
env: CLIPPY=YESPLEASE
before_script: rustup component add clippy-preview
script: cargo clippy --all -- -D warnings
- rust: 1.29.1
- rust: 1.36.0
env: RUSTFMT=YESPLEASE
before_script: rustup component add rustfmt-preview
script: cargo fmt --all -- --check
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>",
"Pascal Hertleif <killercup@gmail.com>",
"Katharina Fey <kookie@spacekookie.de>"]
readme = "README.md"
edition = "2018"

[package.metadata.docs.rs]
features = ["nightly"]

[dependencies]
termcolor = "1.0.4"
tempdir = "0.3.7"
uuid = { version = "0.7.1", features = ["v4"] }
uuid = { version = "0.7.1", features = ["v4"], default-features = false }
serde_derive = "1.0.79"
toml = "0.4.7"
serde = "1.0.79"
failure = { version = "0.1.2", default-features = false, features = ["std"] }
os_type = "2.2.0"
backtrace = "0.3.9"

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ stack backtrace:
## Usage

```rust no_run
#[macro_use]
extern crate human_panic;
use human_panic::setup_panic;

fn main() {
setup_panic!();
Expand Down
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@
#![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", feature(panic_info_message))]

extern crate backtrace;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate serde_derive;
extern crate termcolor;

pub mod report;
use report::{Method, Report};

Expand Down Expand Up @@ -84,9 +77,8 @@ pub struct Metadata {
/// The Metadata struct can't implement `Default` because of orphan rules, which
/// means you need to provide all fields for initialisation.
///
/// ```ignore
/// #[macro_use]
/// extern crate human_panic;
/// ```
/// use human_panic::setup_panic;
///
/// setup_panic!(Metadata {
/// name: env!("CARGO_PKG_NAME").into(),
Expand Down
20 changes: 5 additions & 15 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
//! A `Report` contains the metadata collected about the event
//! to construct a helpful error message.

extern crate failure;
extern crate os_type;
extern crate serde;
extern crate tempdir;
extern crate toml;
extern crate uuid;

use self::failure::Error;
use self::uuid::Uuid;
use backtrace::Backtrace;
use serde_derive::Serialize;
use std::borrow::Cow;
use std::error::Error;
use std::fmt::Write as FmtWrite;
use std::mem;
use std::{env, fs::File, io::Write, path::Path, path::PathBuf};
use uuid::Uuid;

/// Method of failure.
#[derive(Debug, Serialize, Clone, Copy)]
Expand Down Expand Up @@ -135,15 +129,11 @@ impl Report {
}

/// Write a file to disk.
pub fn persist(&self) -> Result<PathBuf, Error> {
pub fn persist(&self) -> Result<PathBuf, Box<dyn Error + 'static>> {
let uuid = Uuid::new_v4().to_hyphenated().to_string();
let tmp_dir = env::temp_dir();
let tmp_dir = match tmp_dir.to_str() {
Some(dir) => dir,
None => bail!("Could not create a tmp directory for a report."),
};
let file_name = format!("report-{}.toml", &uuid);
let file_path = Path::new(tmp_dir).join(file_name);
let file_path = Path::new(&tmp_dir).join(file_name);
let mut file = File::create(&file_path)?;
let toml = self.serialize().unwrap();
file.write_all(toml.as_bytes())?;
Expand Down
3 changes: 2 additions & 1 deletion tests/custom-panic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "custom-panic-test"
version = "0.1.0"
authors = ["Human Panic Authors <human-panic-crate@example.com>"]
edition = "2018"

[dependencies]
human-panic = { path = "../.." }

[dev-dependencies]
assert_cli = "0.5.4"
assert_cli = "0.6.3"
3 changes: 1 addition & 2 deletions tests/custom-panic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[macro_use]
extern crate human_panic;
use human_panic::setup_panic;

fn main() {
setup_panic!(Metadata {
Expand Down
2 changes: 1 addition & 1 deletion tests/custom-panic/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate assert_cli;
use assert_cli;

#[test]
fn release() {
Expand Down
3 changes: 2 additions & 1 deletion tests/single-panic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "single-panic-test"
version = "0.1.0"
authors = ["Human Panic Authors <human-panic-crate@example.com>"]
edition = "2018"

[dependencies]
human-panic = { path = "../.." }

[dev-dependencies]
assert_cli = "0.5.4"
assert_cli = "0.6.3"
3 changes: 1 addition & 2 deletions tests/single-panic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[macro_use]
extern crate human_panic;
use human_panic::setup_panic;

fn main() {
setup_panic!();
Expand Down
2 changes: 1 addition & 1 deletion tests/single-panic/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate assert_cli;
use assert_cli;

#[test]
fn release() {
Expand Down