Skip to content

parse(): thow an error when parsing is unsuccessful  #148

@meodai

Description

@meodai

It would be very practical, if parse would throw an error if it was not successful in parsing a color.

try {
  const color = culori.parse('something');
  console.log({color}); // {{ color: undefined }}
} catch (error) {
  console.error(error);
}

The only way I can do this now is check for undefined.
I'd find it very practical to get something like:

throw new Error(
   `parse() must be an object or a valid color string but \`${arguments}\` were given.`
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions