Skip to content

feat: onError property for RiveView#25

Merged
mfazekas merged 10 commits into
mainfrom
mfazekas/on-error
Nov 20, 2025
Merged

feat: onError property for RiveView#25
mfazekas merged 10 commits into
mainfrom
mfazekas/on-error

Conversation

@mfazekas
Copy link
Copy Markdown
Collaborator

@mfazekas mfazekas commented Nov 19, 2025

Introduce onError() callback on RiveView. This is a required fn and defaults to console.error

onError(error: {message: string, type: RiveErrorType})
image

@mfazekas mfazekas marked this pull request as ready for review November 19, 2025 07:26
@mfazekas mfazekas requested a review from Copilot November 19, 2025 07:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an onError callback property to the RiveView component, allowing consumers to handle errors that occur during Rive animation rendering and configuration. The implementation includes a default error handler that logs to console.error and provides a structured RiveError type with both a message and an error type enum for categorization.

Key changes:

  • Added RiveError interface and RiveErrorType enum for structured error handling
  • Introduced onError callback prop on RiveView with a default console.error handler
  • Replaced native logging in error handlers with callback invocation on both iOS and Android platforms

Reviewed Changes

Copilot reviewed 9 out of 37 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/specs/RiveView.nitro.ts Added onError property to native interface specification
src/index.tsx Refactored to wrap native component and expose new RiveViewRef type
src/core/RiveView.tsx Created wrapper component with default error handler and updated documentation
src/core/Errors.ts Defined RiveError interface and RiveErrorType enum with 8 error categories
src/hooks/useRive.ts Updated to use new RiveViewRef type for improved type safety
nitrogen/generated/* Auto-generated bindings for C++, Swift, and Kotlin platforms
ios/HybridRiveView.swift Implemented error detection and callback invocation for iOS
ios/RiveReactNativeView.swift Updated configuration methods to throw errors instead of silently failing
ios/Utils.swift Removed generic logged utility function (moved to component-specific implementation)
android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt Implemented error detection and callback invocation for Android

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt Outdated
Comment thread android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt Outdated
Comment thread ios/HybridRiveView.swift
Comment thread src/core/RiveView.tsx Outdated
Comment thread ios/HybridRiveView.swift Outdated
Comment thread android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt
Comment thread src/index.tsx Outdated
Comment thread src/specs/RiveView.nitro.ts
Comment thread src/core/RiveView.tsx Outdated
Comment thread ios/HybridRiveView.swift Outdated
Comment thread src/core/Errors.ts Outdated
Comment thread ios/HybridRiveView.swift Outdated
Comment thread ios/HybridRiveView.swift Outdated
Comment thread ios/HybridRiveView.swift Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 11 out of 39 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/specs/RiveView.nitro.ts
Comment thread ios/HybridRiveView.swift
Comment thread android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt
Comment thread src/core/Errors.ts
mfazekas and others added 7 commits November 19, 2025 16:27
- Fix import cycle by extracting NitroRiveView to separate file
- Make error types human-readable in logs (show enum names instead of numbers)
- Improve iOS error detection using RiveErrorCode enum values instead of string comparisons
- Rename NativeRiveError to NitroRiveError for consistency with Nitro Modules naming
- Make detectErrorType return tuple with both error type and message
- Add NitroRiveError.fileNotFound case for asset loading errors
- Remove non-existent error types (TextRunNotFoundError, IncorrectAnimationName)
- Map instanceNotFound errors to DataBindingError type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add IncorrectAnimationName and IncorrectStateMachineInputName error types
- Fix iOS to map noStateMachineInputFound to
  IncorrectStateMachineInputName instead of IncorrectAnimationName
- Fix Android to use correct error types instead of UNKNOWN
- Regenerate Nitrogen bindings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename DataBindingError to ViewModelInstanceNotFound
- Remove IncorrectAnimationName (map to Unknown)
- Remove TextRunNotFoundError (map to Unknown)
- Make Android detectErrorType return Pair<RiveErrorType, String>
  for consistency with iOS
- Update both platforms to use cleaner error messages
- Regenerate Nitrogen bindings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
HayesGordon
HayesGordon previously approved these changes Nov 20, 2025
Copy link
Copy Markdown
Contributor

@HayesGordon HayesGordon left a comment

Choose a reason for hiding this comment

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

LGTM!

@mfazekas mfazekas merged commit c810553 into main Nov 20, 2025
5 checks passed
@HayesGordon HayesGordon deleted the mfazekas/on-error branch December 9, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants