-
Notifications
You must be signed in to change notification settings - Fork 144
Print error code texts #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
urfeex
wants to merge
20
commits into
UniversalRobots:master
Choose a base branch
from
urfeex:error_codes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c8687b0
Add string replacement of logged error codes
urfeex 58b822b
Add a github workflow to check whether the current error codes json i…
urfeex 6ffbc6a
Change formatting to always contain the error code
urfeex 95fd9df
Add unit tests for toString()
urfeex f989fb9
Apply batched suggestions from code review
urfeex 2eeb1e4
Add missing file
urfeex 0efd0c9
Open a PR updating the error_codes when a newer json is available
urfeex 10b360d
Apply batched suggestions from code review
urfeex 74662de
Use proper string formatting
urfeex 83e2dd7
Potential fix for pull request finding
urfeex c32146c
Potential fix for pull request finding
urfeex 936af1d
Correct path in comment
urfeex ab233af
Formatting
urfeex b5934ff
Update workflow
urfeex 621aa4e
Fix literal handling
urfeex 8c7edb8
Make sure the header file has always the copyright year of creating it.
urfeex ca082cd
Revert removing the A-1 part for unset arguments
urfeex 2dc3c7b
Enforce valid version numbers
urfeex 68bc2cc
Ignore generate_error_codes.py in coverage
urfeex 37841f3
Potential fix for pull request finding
urfeex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| name: Check UR ErrorCodes version | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: '0 6 * * *' # Every night at 06:00 UTC | ||
|
|
||
| jobs: | ||
| check_error_codes: | ||
| name: Check UR ErrorCodes JSON version | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write # push update branch | ||
| issues: write # open notification issue | ||
| pull-requests: write # open PR with the regenerated header | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - name: Check error codes version | ||
| id: check | ||
| # continue-on-error so subsequent steps can still run and open a PR/issue | ||
| continue-on-error: true | ||
| run: | | ||
| python3 scripts/generate_error_codes.py \ | ||
| --check \ | ||
| --header include/ur_client_library/ur/error_code_texts.h | ||
|
|
||
| - name: Extract versions | ||
| if: steps.check.outcome == 'failure' | ||
| id: versions | ||
| run: | | ||
| COMMITTED=$(python3 -c " | ||
| import re | ||
| m = re.search(r'ERROR_CODE_JSON_VERSION\s*=\s*\"([^\"]+)\"', | ||
| open('include/ur_client_library/ur/error_code_texts.h').read()) | ||
| print(m.group(1) if m else 'unknown') | ||
| ") | ||
| UPSTREAM=$(python3 -c " | ||
| import urllib.request, json | ||
| data = json.loads(urllib.request.urlopen( | ||
| 'https://www.universal-robots.com/manuals/EN/PDF/Shared/ErrorCodes/ErrorCodes.json' | ||
| ).read()) | ||
| print(data.get('version', 'unknown')) | ||
| ") | ||
| # Validate both versions match N.N.N before using them in branch | ||
| # names, PR titles, and commit messages. An unexpected format | ||
| # (e.g. containing '/', '"', or newlines) would otherwise allow | ||
| # injection into those fields. | ||
| VERSION_RE='^[0-9]+\.[0-9]+\.[0-9]+$' | ||
| if ! echo "$COMMITTED" | grep -qE "$VERSION_RE"; then | ||
| echo "ERROR: committed version '$COMMITTED' does not match expected N.N.N format" >&2 | ||
| exit 1 | ||
| fi | ||
| if ! echo "$UPSTREAM" | grep -qE "$VERSION_RE"; then | ||
| echo "ERROR: upstream version '$UPSTREAM' does not match expected N.N.N format" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "committed=$COMMITTED" >> "$GITHUB_OUTPUT" | ||
| echo "upstream=$UPSTREAM" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Ensure label exists | ||
| if: steps.check.outcome == 'failure' && steps.versions.outcome == 'success' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh label create "error-codes-outdated" \ | ||
| --description "Upstream UR ErrorCodes JSON has a newer version than the committed header" \ | ||
| --color "e4e669" \ | ||
| --force | ||
|
|
||
| - name: Regenerate header and open PR | ||
| if: steps.check.outcome == 'failure' && steps.versions.outcome == 'success' | ||
| id: pr | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| COMMITTED: ${{ steps.versions.outputs.committed }} | ||
| UPSTREAM: ${{ steps.versions.outputs.upstream }} | ||
| run: | | ||
| BRANCH="auto/update-error-codes-v${UPSTREAM}" | ||
|
|
||
| # Skip if a PR for exactly this branch is already open | ||
| OPEN_PR=$(gh pr list \ | ||
| --label "error-codes-outdated" \ | ||
| --state open \ | ||
| --json headRefName \ | ||
| --jq "[.[] | select(.headRefName == \"$BRANCH\")] | length") | ||
|
|
||
| if [ "$OPEN_PR" -gt 0 ]; then | ||
| echo "PR for branch $BRANCH already open — skipping." | ||
| echo "pr_url=" >> "$GITHUB_OUTPUT" | ||
| else | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "$BRANCH" | ||
|
|
||
| python3 scripts/generate_error_codes.py \ | ||
| --overlay scripts/error_code_overrides.json \ | ||
| --output include/ur_client_library/ur/error_code_texts.h | ||
|
|
||
| git add include/ur_client_library/ur/error_code_texts.h | ||
| git commit -m "chore: update error_code_texts.h to UR ErrorCodes JSON v${UPSTREAM}" | ||
| git push origin "$BRANCH" | ||
|
urfeex marked this conversation as resolved.
|
||
|
|
||
| PR_URL=$(gh pr create \ | ||
| --title "chore: update error_code_texts.h to UR ErrorCodes JSON v${UPSTREAM}" \ | ||
| --label "error-codes-outdated" \ | ||
| --base "${{ github.event.repository.default_branch }}" \ | ||
| --head "$BRANCH" \ | ||
| --body "The upstream UR ErrorCodes JSON has been updated. This PR regenerates \`error_code_texts.h\` automatically. | ||
|
|
||
| | | Version | | ||
| |---|---| | ||
| | Previous header (\`ERROR_CODE_JSON_VERSION\`) | \`${COMMITTED}\` | | ||
| | Upstream JSON | \`${UPSTREAM}\` | | ||
|
|
||
| **Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
|
|
||
| > [!NOTE] | ||
| > Only \`include/ur_client_library/ur/error_code_texts.h\` is updated here. | ||
| > If you have pending entries in \`scripts/error_code_overrides.json\`, verify | ||
| > they are still correct against the new JSON before merging.") | ||
|
|
||
| echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| - name: Fail if version mismatch | ||
| if: steps.check.outcome == 'failure' | ||
| run: exit 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- | ||
|
|
||
| // -- BEGIN LICENSE BLOCK ---------------------------------------------- | ||
| // Copyright 2026 Universal Robots A/S | ||
| // | ||
| // Redistribution and use in source and binary forms, with or without | ||
| // modification, are permitted provided that the following conditions are met: | ||
| // | ||
| // * Redistributions of source code must retain the above copyright | ||
| // notice, this list of conditions and the following disclaimer. | ||
| // | ||
| // * Redistributions in binary form must reproduce the above copyright | ||
| // notice, this list of conditions and the following disclaimer in the | ||
| // documentation and/or other materials provided with the distribution. | ||
| // | ||
| // * Neither the name of the copyright holder nor the names of its | ||
| // contributors may be used to endorse or promote products derived from | ||
| // this software without specific prior written permission. | ||
| // | ||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| // POSSIBILITY OF SUCH DAMAGE. | ||
| // -- END LICENSE BLOCK ------------------------------------------------ | ||
|
|
||
| //---------------------------------------------------------------------- | ||
| /*!\file | ||
| * | ||
| * Declaration of the dynamic error-code text override hook. | ||
| * | ||
| * Edit src/ur/error_code_overrides.cpp to add | ||
| * runtime-computed descriptions for specific error codes. That file | ||
| * is intentionally NOT touched by the code-generation script. | ||
| * | ||
| */ | ||
| //---------------------------------------------------------------------- | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| namespace urcl | ||
| { | ||
| namespace primary_interface | ||
| { | ||
| /*! | ||
| * \brief Optional dynamic override for an error code text. | ||
| * | ||
| * Called by ErrorCodeMessage::toString() before the static lookup table. | ||
| * Return a non-empty optional to supply a custom description; return | ||
| * std::nullopt to fall through to the generated table. | ||
| * | ||
| * Implement additional cases in | ||
| * src/ur/error_code_overrides.cpp. | ||
| * | ||
| * \param code The error code (message_code_) | ||
| * \param arg The error argument (message_argument_) | ||
| * \returns A human-readable string, or std::nullopt | ||
| */ | ||
| std::optional<std::string> getErrorCodeTextOverride(int32_t code, int32_t arg); | ||
|
|
||
| } // namespace primary_interface | ||
| } // namespace urcl |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.