avoid printing full error during development #59
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When developing locally it is common to create a feature flag in code before actually creating it in the feature flag provider, and to then use Flags Explorer to override this flag and continue development.
This works fine when a
defaultValue
is declared. However the feature flag provider will - expectedly - not find the feature flag yet, and usually emit an error. This has the negative effect that we currently print the whole error the flag provider emits to the console, even though this is expected. This is quite distracting.This PR reduces the log level by downgrading the log to a
console.info
, and by omitting the error itself from the log.Before
After
For preview and production environments we continue to show the full error, as you would expect the feature flag to be declared in those environments.
To see the full error during development you can temporarily remove the
defaultValue
from the declaration, which will make theflag
function throw the actual error.Alternatives considered
console.groupCollapsed
to log the warning and show the full error in a collapsed state during development.