Skip to content

Commit d964eac

Browse files
mscdexaddaleax
authored andcommitted
doc: remove redundant warning information
process.emitWarning() already describes how to emit custom warnings, so just merely provide a link to that function from the 'warning' event documentation. PR-URL: #9590 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 25a6f88 commit d964eac

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

doc/api/process.md

+5-44
Original file line numberDiff line numberDiff line change
@@ -312,50 +312,6 @@ $ node --no-warnings
312312
The `--trace-warnings` command-line option can be used to have the default
313313
console output for warnings include the full stack trace of the warning.
314314

315-
#### Emitting custom warnings
316-
317-
The [`process.emitWarning()`][process_emit_warning] method can be used to issue
318-
custom or application specific warnings.
319-
320-
```js
321-
// Emit a warning using a string...
322-
process.emitWarning('Something happened!');
323-
// Prints: (node 12345) Warning: Something happened!
324-
325-
// Emit a warning using an object...
326-
process.emitWarning('Something Happened!', 'CustomWarning');
327-
// Prints: (node 12345) CustomWarning: Something happened!
328-
329-
// Emit a warning using a custom Error object...
330-
class CustomWarning extends Error {
331-
constructor(message) {
332-
super(message);
333-
this.name = 'CustomWarning';
334-
Error.captureStackTrace(this, CustomWarning);
335-
}
336-
}
337-
const myWarning = new CustomWarning('Something happened!');
338-
process.emitWarning(myWarning);
339-
// Prints: (node 12345) CustomWarning: Something happened!
340-
```
341-
342-
#### Emitting custom deprecation warnings
343-
344-
Custom deprecation warnings can be emitted by setting the `name` of a custom
345-
warning to `DeprecationWarning`. For instance:
346-
347-
```js
348-
process.emitWarning('This API is deprecated', 'DeprecationWarning');
349-
```
350-
351-
Or,
352-
353-
```js
354-
const err = new Error('This API is deprecated');
355-
err.name = 'DeprecationWarning';
356-
process.emitWarning(err);
357-
```
358-
359315
Launching Node.js using the `--throw-deprecation` command line flag will
360316
cause custom deprecation warnings to be thrown as exceptions.
361317

@@ -368,6 +324,11 @@ of the custom deprecation.
368324
The `*-deprecation` command line flags only affect warnings that use the name
369325
`DeprecationWarning`.
370326

327+
#### Emitting custom warnings
328+
329+
See the [`process.emitWarning()`][process_emit_warning] method for issuing
330+
custom or application-specific warnings.
331+
371332
### Signal Events
372333

373334
<!--type=event-->

0 commit comments

Comments
 (0)