Skip to content

RiveViewModel constructors use try! disallowing graceful error handling #380

@tomekfab

Description

@tomekfab

Description

RiveViewModel constructors use a lot of force try and force unwrapping. Whenever we accidentally provide a wrong state machine name or smth of that sorts our app crash, while without try! we could gracefully handle this.

Provide a Repro

Just init a RiveViewModel with misspelled state machine and you will get:

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: RiveRuntime.RiveModel.RiveModelError.invalidStateMachine("State machine named xxx not found")

There are errors being thrown that you don't let us handle.

Source .riv/.rev file

not needed

Expected behavior

init throws an error, which we can then handle

Screenshots

Device & Versions (please complete the following information)

  • Device: any
  • iOS version any

Additional context

https://github.com/rive-app/rive-ios/blob/63bb20eb0a23be4121bfffea30e0d287677d4ac4/Source/RiveViewModel.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions