{"record":{"id":"7d02403a74d20b79","repo":"winstonjs/winston","slug":"deprecated-handleexceptions-will-be-removed-in","errorCode":null,"errorMessage":"Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()","messagePattern":"Deprecated: \\.handleExceptions\\(\\) will be removed in winston@4\\. Use \\.exceptions\\.handle\\(\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/winston/logger.js","lineNumber":614,"sourceCode":"      const info = typeof args[args.length - 1] === 'object' ? args.pop() : {};\n      info.level = info.level || 'info';\n      info.durationMs = time - timeEnd;\n      info.message = info.message || id;\n      return this.write(info);\n    }\n\n    this.profilers[id] = time;\n    return this;\n  }\n\n  /**\n   * Backwards compatibility to `exceptions.handle` in winston < 3.0.0.\n   * @returns {undefined}\n   * @deprecated\n   */\n  handleExceptions(...args) {\n    // eslint-disable-next-line no-console\n    console.warn(\n      'Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()'\n    );\n    this.exceptions.handle(...args);\n  }\n\n  /**\n   * Backwards compatibility to `exceptions.handle` in winston < 3.0.0.\n   * @returns {undefined}\n   * @deprecated\n   */\n  unhandleExceptions(...args) {\n    // eslint-disable-next-line no-console\n    console.warn(\n      'Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()'\n    );\n    this.exceptions.unhandle(...args);\n  }\n","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/logger.js#L596-L632","documentation":"logger.handleExceptions() is a winston < 3.0.0 backwards-compatibility shim. When called it warns that it will be removed in winston@4 and delegates to logger.exceptions.handle(). Code keeps working today but should migrate before the v4 release removes the method.","triggerScenarios":"Any call to logger.handleExceptions(transport) or winston.handleExceptions(...) on a v3 logger — the warning fires on every invocation at logger.js:614.","commonSituations":"Upgraded winston 2.x codebases where handleExceptions was the standard way to catch uncaught errors; tutorials/docs predating v3; gradual migration where the deprecation warning is overlooked in logs.","solutions":["Replace logger.handleExceptions(...) with logger.exceptions.handle(...) — same arguments, modern API.","Alternatively pass an 'exceptionHandlers' option object to winston.createLogger({...}).","Search the codebase for handleExceptions and update all call sites plus tests before upgrading to winston@4."],"exampleFix":"// before\nlogger.handleExceptions(new winston.transports.File({ filename: 'exceptions.log' }));\n// after\nlogger.exceptions.handle(new winston.transports.File({ filename: 'exceptions.log' }));","handlingStrategy":"validation","validationCode":"// codemod: replace legacy call\n// grep -rn 'handleExceptions(' src/ && update to exceptions.handle\nfunction setupExceptions(logger, ...transports) {\n  if (typeof logger.handleExceptions === 'function' && !logger.exceptions) {\n    logger.handleExceptions(...transports); // winston v2 path\n  } else {\n    logger.exceptions.handle(...transports); // winston v3+\n  }\n}","typeGuard":"const needsMigration = (logger) => typeof logger.handleExceptions === 'function' && typeof logger.exceptions?.handle === 'function';","tryCatchPattern":null,"preventionTips":["Use logger.exceptions.handle() exclusively in new code.","Add an ESLint no-restricted-properties rule against handleExceptions.","Prefer declaring exceptionHandlers in createLogger options over post-hoc registration."],"tags":["winston","deprecation","handleexceptions","migration"],"backgroundTag":"deprecated-api-usage","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}