8/11/2015

Error Handle

Description

By these 2 reasons,
1. Python output run time error to standard error.
2. Some BIOS standard error is not the same as standard output.

We can use try ... exception for output error to standard output
print traceback.format_exc()

Sample code

#
# EfiPy2Error.py
#

import traceback

import EfiPy2 as EfiPy

from EfiPy2.MdePkg.Protocol.SimpleTextOut import     \
                    gEfiSimpleTextOutProtocolGuid,  \
                    EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL

try:
  Status = EfiPy.gBS.LocateProtocol (
             EfiPy.byref (gEfiSimpleTextOutProtocolGuid),
             None,
             EfiPy.byref (Interface)
             )

except:
  print ("Exception Test")
  print (traceback.format_exc())

Due to variable Interface is not initialed before EfiPy.gBS.LocateProtocol in above code, it is an exception.

screenshot

No comments:

Post a Comment