mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
trace_events: refactor to use validateStringArray
`options.categories` is string[]. So used `validateStringArray` Refs: https://nodejs.org/dist/latest-v19.x/docs/api/tracing.html#trace_eventscreatetracingoptions PR-URL: https://github.com/nodejs/node/pull/46012 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
94199c8ab6
commit
8a74477ddf
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
ArrayIsArray,
|
||||
ArrayPrototypeJoin,
|
||||
SafeSet,
|
||||
Symbol,
|
||||
@ -17,7 +16,6 @@ const kMaxTracingCount = 10;
|
||||
const {
|
||||
ERR_TRACE_EVENTS_CATEGORY_REQUIRED,
|
||||
ERR_TRACE_EVENTS_UNAVAILABLE,
|
||||
ERR_INVALID_ARG_TYPE
|
||||
} = require('internal/errors').codes;
|
||||
|
||||
const { ownsProcessState } = require('internal/worker');
|
||||
@ -29,6 +27,7 @@ const { customInspectSymbol } = require('internal/util');
|
||||
const { format } = require('internal/util/inspect');
|
||||
const {
|
||||
validateObject,
|
||||
validateStringArray,
|
||||
} = require('internal/validators');
|
||||
|
||||
const enabledTracingObjects = new SafeSet();
|
||||
@ -84,11 +83,7 @@ class Tracing {
|
||||
|
||||
function createTracing(options) {
|
||||
validateObject(options, 'options');
|
||||
|
||||
if (!ArrayIsArray(options.categories)) {
|
||||
throw new ERR_INVALID_ARG_TYPE('options.categories', 'string[]',
|
||||
options.categories);
|
||||
}
|
||||
validateStringArray(options.categories, 'options.categories');
|
||||
|
||||
if (options.categories.length <= 0)
|
||||
throw new ERR_TRACE_EVENTS_CATEGORY_REQUIRED();
|
||||
|
Loading…
Reference in New Issue
Block a user