1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45//! A macro to generate pseudo directory trees using a small DSL.
67use zx_status::Status;
89/// A helper function used by the `pseudo_directory!` macro, to report nice errors in case
10/// add_entry() fails.
11#[doc(hidden)]
12pub fn unwrap_add_entry_span(entry: &str, location: &str, res: Result<(), Status>) {
13if res.is_ok() {
14return;
15 }
1617let status = res.unwrap_err();
18let text;
19let error_text = match status {
20 Status::ALREADY_EXISTS => "Duplicate entry name.",
21_ => {
22 text = format!("`add_entry` failed with an unexpected status: {}", status);
23&text
24 }
25 };
2627panic!(
28"Pseudo directory tree generated via pseudo_directory! macro\n\
29 {}\n\
30 {}\n\
31 Entry: '{}'",
32 location, error_text, entry
33 );
34}