Description
We’ve always thought that running all the messages of Frontity through the same API could be a good idea, to add things like a link to the community.
Let’s explore what possible use cases could have such package.
User Stories
As a package developer
I want to have a standard way to add console warnings
so that those messages have links to the community (or other useful information)
As a package developer
I want to have standard way to throw errors
so that those messages have links to the community (or other useful information)
Also, we could avoid those messages in production:
As a package developer
I don’t want my console warning in production
so that we don’t annoy the final readers
Please add as many use cases as you imagine.
Possible solution
Create a frontity package for messages that will centralize this:
import { warn, error } from "@frontity/error";
warn("You are missing one setting in your frontity.settings file");
error("Something went wrong!");
The implementation would be something like:
const community = msg => msg + "\nVisit community.frontity.org for help";
const warn = msg =>
process.env.NODE_ENV === "development" && console.warn(community(msg));
const error = msg => throw new Error(community(msg));
Maybe we could add an options
object:
warn(
"You are missing one setting in your frontity.settings file",
{ production: true }
);