Skip to content

Handle exceptions when rendering icon previews and log warnings#1005

Merged
egorikftp merged 1 commit into
mainfrom
bug/idea/preview
May 29, 2026
Merged

Handle exceptions when rendering icon previews and log warnings#1005
egorikftp merged 1 commit into
mainfrom
bug/idea/preview

Conversation

@egorikftp

@egorikftp egorikftp commented May 28, 2026

Copy link
Copy Markdown
Member

📝 Changelog

If this PR introduces user-facing changes, please update the relevant Unreleased section in changelogs:

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds exception handling to the icon rendering pipeline in the Valkyrie IDEA plugin. The renderImage() method in ImageVectorIcon now wraps the VdPreview.getPreviewFromVectorXml() call in a try/catch block to gracefully handle failures with invalid path data, returning null instead of crashing the IDE. Logging for non-empty error states was also downgraded from error-level to warning-level with updated message formatting. The changelog documents this fix under the "Unreleased" section.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR implements exception handling and warning logging for icon rendering, but it is unclear whether the specific root cause (missing initial moveto in path definition) is fully addressed. Verify that the try-catch approach in ImageVectorIcon.renderImage() actually prevents IllegalPathStateException and that path conversion logic handles missing moveto cases properly.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: handling exceptions during icon preview rendering and logging warnings.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: adding exception handling for icon preview rendering and updating the changelog appropriately.
Description check ✅ Passed The pull request description follows the required template structure by including the issue reference and the changelog checklist section with appropriate selections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/idea/preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/completion/ImageVectorIcon.kt (1)

71-81: ⚡ Quick win

Consider a more generic exception message.

The warning message assumes "invalid path data" but the caught exception could be due to other causes (e.g., memory issues, internal VdPreview failures, thread interruption). While "invalid path data" is accurate for the primary use case from issue #1004, a more generic message would be safer.

💬 Suggested improvement
         } catch (e: Exception) {
             Logger.getInstance(ImageVectorIcon::class.java)
-                .warn("Failed to render icon preview (invalid path data): ${e.message}")
+                .warn("Failed to render icon preview: ${e.message}")
             return null
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/completion/ImageVectorIcon.kt`
around lines 71 - 81, The catch block in ImageVectorIcon around
VdPreview.getPreviewFromVectorXml currently logs a specific "invalid path data"
message; change it to a more generic warning that does not assume the root cause
and include the caught exception details (e.message and/or e::class.simpleName)
for context. Update the Logger.getInstance(ImageVectorIcon::class.java).warn
call to a neutral message like "Failed to render icon preview" and append the
exception type and message from the caught Exception to help debugging while
avoiding incorrect assumptions about the error source.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/completion/ImageVectorIcon.kt`:
- Around line 71-81: The catch block in ImageVectorIcon around
VdPreview.getPreviewFromVectorXml currently logs a specific "invalid path data"
message; change it to a more generic warning that does not assume the root cause
and include the caught exception details (e.message and/or e::class.simpleName)
for context. Update the Logger.getInstance(ImageVectorIcon::class.java).warn
call to a neutral message like "Failed to render icon preview" and append the
exception type and message from the caught Exception to help debugging while
avoiding incorrect assumptions about the error source.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1320bb32-41d7-4ddf-a501-899d4fe7c888

📥 Commits

Reviewing files that changed from the base of the PR and between 91633fa and dad151b.

📒 Files selected for processing (2)
  • tools/idea-plugin/CHANGELOG.md
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/completion/ImageVectorIcon.kt

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@egorikftp egorikftp merged commit 285e808 into main May 29, 2026
3 of 4 checks passed
@egorikftp egorikftp deleted the bug/idea/preview branch May 29, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants