Skip to content

[Bug]: Error messages need cleaned up #182

Open
@makubacki

Description

@makubacki

Contact Details

No response

Describe the Bug

Function in the codebase assume errors in places they should not. This leads to erroneous error printing which can increase if these functions are called more often in the future.

This is particularly true for "helper" functions. The function has no context of the caller's intentions. Therefore, it should not consider being called an error.

For example:

https://github.com/tianocore/edk2-pytool-library/blob/master/edk2toollib/uefi/edk2/path_utilities.py

GetContainingPackage() outputs error messages if the given input path is not in package. That might not be an error. The caller might simply want to check if the path is in a package. Only the caller can determine if the presence of the given path in or out of a package is an error.

Some functions such as def GetAbsolutePathOnThisSystemFromEdk2RelativePath(self, relpath, log_errors=True) allow the caller to control error printing but this complicates the function interface for no reason. The caller can easily print an error based on the function return value; the function simply needs to return that value.

Reproduction steps

Perform source code review of functions in this repository for cases where error messages are printed based on assumptions about the caller.

Expected behavior

Error messages are only printed in the cases of true errors. If an exceptional circumstance occurs outside the defined return value of the function, exceptions should be used and documented.

Execution Environment

No response

Pip packages

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions