Skip to content

Commit dbcaa78

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Return Result from ProfileData::gen
Summary: `ProfileData` later in the stack does serialization, not just `String::clone`, so it may fail. Reviewed By: milend Differential Revision: D38681026 fbshipit-source-id: d236920c817787c2c3bb1f4d2865f690ba688923
1 parent 472f9a9 commit dbcaa78

File tree

1 file changed

+3
-3
lines changed
  • starlark/src/eval/runtime/profile

1 file changed

+3
-3
lines changed

starlark/src/eval/runtime/profile/data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ impl ProfileData {
3939
}
4040

4141
/// Generate a string with profile data (e.g. CSV or flamegraph, depending on profile type).
42-
pub fn gen(&self) -> String {
43-
self.profile.clone()
42+
pub fn gen(&self) -> anyhow::Result<String> {
43+
Ok(self.profile.clone())
4444
}
4545

4646
/// Write to a file.
4747
pub fn write(&self, path: &Path) -> anyhow::Result<()> {
48-
fs::write(path, &self.profile).with_context(|| {
48+
fs::write(path, &self.gen()?).with_context(|| {
4949
format!(
5050
"write profile `{}` data to `{}`",
5151
self.profile_mode,

0 commit comments

Comments
 (0)