Skip to content

please change your code to throw in error conditions rather than return null #796

Open
@olsonpm

Description

@olsonpm

How would the enhancement work?

So far I've seen this pattern in createInstance and createUserExperience

  • createInstance should throw instead of return null when an error occurs. i.e. the try/catch should be removed here
  • createUserExperience should throw when input is invalid with an error message explaining why. Returning null gives the devs no clue as to what went wrong or why - just that something went wrong. It is an error and should be treated as such

When would the enhancement be useful?

because returning null in error scenarios doesn't make sense. Devs naturally expect an error to bubble with the proper stack trace and error information rather than the function to return successfully and have to write the error edge case themselves.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions