Errors/Warning commands

Roadmap Card

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 }
);

Finally we are going to implement this API:

import { warn, error } from "frontity";

warn("You are missing one setting in your frontity.settings file");

error("Something went wrong!");
1 Like

This has been implemented in https://github.com/frontity/frontity/pull/256 in line with:

Uh, I think we forgot to add this to the docs: https://docs.frontity.org/api-reference-1/frontity#api-reference

@documentation-team how should we proceed? Are you tracking somewhere the missing things?

@luisherranz you can directly create a task at our internal Documentation Roadmap in notion (that will be public at some point)

We’re working on a document that will explain the ways anyone have to suggest changes to the documentation but a first approach could be:

  • If you’re part of the Frontity Team, you can directly create a task in our internal Documentation Roadmap and explain the details of it
  • If you’re not part of the Frontity Team, for now you can:
    • Directly suggest a change by creating a PR on the proper document (or documents) in the gitbook_docs repo
    • Open a thread in Docs & Tutorials to suggest your changes
    • Open an issue in gitbook_docs repo to suggest your changes

In this specific case (updating the API reference) I would suggest to (in order of preference):

  1. Directly suggest the change by creating a PR on the proper document (or documents) gitbook_docs repo
  2. Create a task in our internal Documentation Roadmap explain the details, the priority and all the references the DevRel team could need to complete the task

Done :slight_smile:

Thanks @juanma!