Skip to content

Should we throw an exception when no service is available? #897

@CharliePoole

Description

@CharliePoole

As I've been doing some work on removal of the UserSettings and RecentFiles services, I have noticed a problem with the API. When a user requests a service by calling GetService we return null if the service is not available. This was intended to allow flexibility when a particular service is not available. However, I find that it can lead to a lot of debugging when the return value is simply saved and the caller tries to use it at a later time.

Maybe for V4 we should throw an exception in this situation and supply a TryGetService method for those who deliberately choose the flexibility.

The interface we would have to change is IServiceLocator

Metadata

Metadata

Assignees

Labels

FeatureNeeds DesignV4All issues related to V4 or later - use -label:V4 to get V3 issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions