Skip to content

Custom path to save a panic report #167

@rucoder

Description

@rucoder

Currently Report::persist uses env::temp_dir() to get a base folder to save a panic report

    /// Write a file to disk.
    pub fn persist(&self) -> Result<PathBuf, Box<dyn Error + 'static>> {
        let uuid = Uuid::new_v4().hyphenated().to_string();
        let tmp_dir = env::temp_dir();
        let file_name = format!("report-{}.toml", &uuid);
        let file_path = Path::new(&tmp_dir).join(file_name);
        let toml = self.serialize().expect("only using toml-compatible types");
        std::fs::write(&file_path, toml.as_bytes())?;
        Ok(file_path)
    }

However on some platforms TMPDIR may not be defined or be RO (yes, weird but true) . Sure TMPDIR may be overwritten when starting application however it would be nice to configure a base dir either as a parameter to ::handle_dump (breaking change) of through Metadata object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions