parse(): thow an error when parsing is unsuccessful
Open
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
Assessment
This issue has not been assessed yet.