Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Suggestion to improve usability of VPN notification observation #413

@tomasjablonskis

Description

@tomasjablonskis

Summary

While observing the VPN status notification using NotificationCenter and this libraries VPNNotification struct app crashes when attempting to retrieve a value that does not currently exist.

Steps to reproduce

Start observing VPN status using:

NotificationCenter.default.addObserver(
    self,
    selector: #selector(...),
    name: VPNNotification.didChangeStatus,
    object: nil
)

Connect to VPN and try to retrieve notification.vpnError in your notification reciever.

What is the current bug behavior?

App crashes with uncatchable exception (fatalError(...)).

What is the expected correct behavior?

A catchable exception is thrown.

Relevant logs and/or screenshots

image

Possible fixes suggested remediation

The least you can do is instead of using fatalError(...) if value does not exist in userInfo throw a catchable exception, but would prefer to somehow recieve an enum/result value of either error/status in VPN status notification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions