Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maxDepth option #18

Closed
wants to merge 5 commits into from

Conversation

gillesdemey
Copy link

fixes #16

@OsoianMarcel

This comment has been minimized.

index.js Outdated Show resolved Hide resolved
index.test-d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Can you add some proper API docs in the readme for the option? Example of how I tend to do it: https://github.com/sindresorhus/boxen#api

@gillesdemey
Copy link
Author

I've added an API section to the README 👍

@gillesdemey
Copy link
Author

Trying to move the ball forward on this one, are the new API docs sufficient? :)

@@ -7,6 +7,10 @@ declare namespace serializeError {
message?: string;
code?: string;
} & JsonObject;

type Options = {
maxDepth: number;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a doc comment with a code example. See how to do that here: https://github.com/sindresorhus/typescript-definition-style-guide#documentation

// Passing `maxDepth` will limit how deep we will copy the error object
const nestedError = {...error, a: {b: 'c'}};
console.log(serializeError(nestedError), {maxDepth: 1});
//=> {name: 'Error', message: 'oops', stack: stack: 'Error: 🦄\n at Object.<anonymous> …', a: {} }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this example should be placed in the docs for the option.

Type: `number`<br>
Default: `Infinity`

Specify a maximum depth on the serialized error object.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it clear enough what "maximum depth" refers to? Maybe mention "properties".

I would also include some use-cases of when this option could be useful.

@sindresorhus sindresorhus changed the title Allow configuring maxDepth to prevent large nested error objects Add maxDepth option Jun 15, 2019
@OsoianMarcel
Copy link

All's fine, but would be awesome to know what properies are hidden/deleted by maxDepth logic.
When we debug logs, it's important to know which propery was really empty, and which one was removed by maxDepth.
If anyone has an idea, please post it here.

@OsoianMarcel
Copy link

At the moment simpliest way is to use

const util = require('util');
const output = util.inspect(bigLongObject, true, 5); // Where 5 is how deep to go

@sindresorhus
Copy link
Owner

@gillesdemey Bump

@sindresorhus
Copy link
Owner

Closing for lack of response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Add a option to indicate how deep to scan Error object
3 participants