mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
Better errors on missing composite disk components.
When there is an error opening one of the composite disk components now, it gives the message `failed to open component file: "No such file or directory (os error 2)"` without specifying the file path it tried to use. Exposing the file path will make it faster to act on errors, rather than trying to examine the composite disk file for paths. TEST=n/a BUG=b:150150052 Change-Id: I9341b330e7e6dcd517d5bfb5262b1657a2da46fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2072738 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
This commit is contained in:
parent
f1f20f59be
commit
dfd0139d7c
1 changed files with 3 additions and 3 deletions
|
@ -24,7 +24,7 @@ pub enum Error {
|
|||
InvalidMagicHeader,
|
||||
InvalidProto(protobuf::ProtobufError),
|
||||
InvalidSpecification(String),
|
||||
OpenFile(io::Error),
|
||||
OpenFile(io::Error, String),
|
||||
ReadSpecificationError(io::Error),
|
||||
UnknownVersion(u64),
|
||||
UnsupportedComponent(ImageType),
|
||||
|
@ -41,7 +41,7 @@ impl Display for Error {
|
|||
InvalidMagicHeader => write!(f, "invalid magic header for composite disk format"),
|
||||
InvalidProto(e) => write!(f, "failed to parse specification proto: \"{}\"", e),
|
||||
InvalidSpecification(s) => write!(f, "invalid specification: \"{}\"", s),
|
||||
OpenFile(e) => write!(f, "failed to open component file: \"{}\"", e),
|
||||
OpenFile(e, p) => write!(f, "failed to open component file \"{}\": \"{}\"", p, e),
|
||||
ReadSpecificationError(e) => write!(f, "failed to read specification: \"{}\"", e),
|
||||
UnknownVersion(v) => write!(f, "unknown version {} in specification", v),
|
||||
UnsupportedComponent(c) => write!(f, "unsupported component disk type \"{:?}\"", c),
|
||||
|
@ -142,7 +142,7 @@ impl CompositeDiskFile {
|
|||
);
|
||||
let file = open_options
|
||||
.open(disk.get_file_path())
|
||||
.map_err(Error::OpenFile)?;
|
||||
.map_err(|e| Error::OpenFile(e, disk.get_file_path().to_string()))?;
|
||||
Ok(ComponentDiskPart {
|
||||
file: create_disk_file(file).map_err(|e| Error::DiskError(Box::new(e)))?,
|
||||
offset: disk.get_offset(),
|
||||
|
|
Loading…
Reference in a new issue