diff options
Diffstat (limited to 'lib/internal/errors.js')
-rw-r--r-- | lib/internal/errors.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js index d6a77b8875..c871f8e8d3 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -18,6 +18,7 @@ const { defineProperty } = Object; // Lazily loaded var util = null; +var buffer; function makeNodeError(Base) { return class NodeError extends Base { @@ -59,6 +60,12 @@ function makeNodeError(Base) { }; } +function lazyBuffer() { + if (buffer === undefined) + buffer = require('buffer').Buffer; + return buffer; +} + // A specialized Error that includes an additional info property with // additional information about the error condition. The code key will // be extracted from the context object or the ERR_SYSTEM_ERROR default @@ -108,7 +115,8 @@ class SystemError extends makeNodeError(Error) { } set path(val) { - this[kInfo].path = val ? Buffer.from(val.toString()) : undefined; + this[kInfo].path = val ? + lazyBuffer().from(val.toString()) : undefined; } get dest() { @@ -117,7 +125,8 @@ class SystemError extends makeNodeError(Error) { } set dest(val) { - this[kInfo].dest = val ? Buffer.from(val.toString()) : undefined; + this[kInfo].dest = val ? + lazyBuffer().from(val.toString()) : undefined; } } |