BaseTools: Improve error messages from UefiCapsuleHeader.py

Instead of throwing ValueErrors with no explanation, add a message
explaining what went wrong.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
This commit is contained in:
Rebecca Cran 2024-12-02 14:36:17 -07:00 committed by mergify[bot]
parent e508c6c08a
commit 5b2d55533b

View File

@ -91,9 +91,9 @@ class UefiCapsuleHeaderClass (object):
Buffer[0:self._StructSize]
)
if HeaderSize < self._StructSize:
raise ValueError
raise ValueError("HeaderSize of {0} doesn't match _StructSize of {1}".format(HeaderSize, self._StructSize))
if CapsuleImageSize != len (Buffer):
raise ValueError
raise ValueError("CapsuleImageSize of {0} doesn't match buffer length of {1}".format(CapsuleImageSize, len(Buffer)))
self.CapsuleGuid = uuid.UUID (bytes_le = CapsuleGuid)
self.HeaderSize = HeaderSize
self.OemFlags = Flags & 0xffff