Evercoder / Evercoder/culori

parse(): thow an error when parsing is unsuccessful

Open
#148 2 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
JavaScript
Stars
1.2k
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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

```js
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:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.