commit | 56b11ffa2f279e6bfa26af586ed75c4b6f501872 | [log] [tgz] |
---|---|---|
author | Jonathon Reinhart <jrreinhart@google.com> | Thu Apr 06 17:03:36 2023 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Thu Apr 06 17:03:36 2023 +0000 |
tree | 16a0ed7042e9babe6429ec7355a3d8c3e0ced8ca | |
parent | 75d2c6ab8788a45c517039fa3c692b649634bf24 [diff] |
pw_presubmit: Fix OwnersError constructor The previous OwnersError.__init__ stored the message argument in a custom attribute rather than passing it to Exception.__init__. This caused str() of the exception to be empty, (or more precisely, repr() to show just the exception type name), leading to a confusing backtrace: 20230405 21:07:40 ERR Presubmit check owners_lint_checks failed! Traceback (most recent call last): ... File ".../pw_presubmit/owners_checks.py", line 131, in __init__ raise OwnersDependencyError(error_msg) pw_presubmit.owners_checks.OwnersDependencyError ^^^???^^^ The use of Exception.message is obsolete: https://stackoverflow.com/q/1272138 We can instead omit OwnersError.__init__ and use the base class Exception.__init__ which accepts a message as the first argument. This fixes the backtrace: 20230406 15:11:15 ERR Presubmit check owners_lint_checks failed! Traceback (most recent call last): ... File ".../pw_presubmit/owners_checks.py", line 126, in __init__ raise OwnersDependencyError( pw_presubmit.owners_checks.OwnersDependencyError: Tried to import .../OWNERS but it does not exist This also required replacing `err.message` with `str(err)` -- or just `err` if it is being formatted with `%s`. Also fixed a typo: "exists" -> "exist". Tested: Ran `pw presubmit --step owners_lint_checks` on a repo with a missing OWNERS file, and confirmed that the error message which was previously missing is now visible. Change-Id: I94301255b1b0360aa9efb8d9f6f93b5f7d5f3639 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/137550 Pigweed-Auto-Submit: Jonathon Reinhart <jrreinhart@google.com> Reviewed-by: Tim Laurence <timlaurence@google.com> Reviewed-by: Rob Mohr <mohrr@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.