koatty_trace
Advanced tools
Comparing version 1.11.2 to 1.12.0
@@ -0,0 +0,0 @@ /* |
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.12.0](https://github.com/koatty/koatty_trace/compare/v1.11.2...v1.12.0) (2024-01-21) | ||
### Bug Fixes | ||
* 优化异常处理 ([88bf495](https://github.com/koatty/koatty_trace/commit/88bf4950fe930023035f2724c0dba2efb24c332e)) | ||
### [1.11.2](https://github.com/koatty/koatty_trace/compare/v1.11.2-0...v1.11.2) (2024-01-16) | ||
@@ -7,0 +14,0 @@ |
/*! | ||
* @Author: richen | ||
* @Date: 2024-01-16 08:17:55 | ||
* @Date: 2024-01-21 13:45:15 | ||
* @License: BSD (3-Clause) | ||
@@ -5,0 +5,0 @@ * @Copyright (c) - <richenlin(at)gmail.com> |
/*! | ||
* @Author: richen | ||
* @Date: 2024-01-16 08:17:43 | ||
* @Date: 2024-01-21 13:45:05 | ||
* @License: BSD (3-Clause) | ||
@@ -15,4 +15,4 @@ * @Copyright (c) - <richenlin(at)gmail.com> | ||
var async_hooks = require('async_hooks'); | ||
var koatty_exception = require('koatty_exception'); | ||
var koatty_logger = require('koatty_logger'); | ||
var koatty_exception = require('koatty_exception'); | ||
var util = require('util'); | ||
@@ -115,3 +115,3 @@ var stream = require('stream'); | ||
* @Date: 2022-02-21 11:32:03 | ||
* @LastEditTime: 2024-01-16 08:10:27 | ||
* @LastEditTime: 2024-01-21 12:56:26 | ||
*/ | ||
@@ -126,20 +126,16 @@ /** | ||
function catcher(ctx, span, err, globalErrorHandler) { | ||
// LOG | ||
koatty_logger.DefaultLogger.Error(err.stack); | ||
if (span) { | ||
span.setTag(opentracing.Tags.ERROR, true); | ||
span.setTag(opentracing.Tags.HTTP_STATUS_CODE, err.status || 500); | ||
span.log({ 'event': 'error', 'error.object': err, 'message': err.message, 'stack': err.stack }); | ||
// 如果是异常对象,直接返回 | ||
if (koatty_exception.isException(err)) { | ||
return err.setSpan(span).handler(ctx); | ||
} | ||
// 执行指定异常处理 | ||
if (koatty_exception.isException(err) && Helper.Helper.isFunction(err.handler)) { | ||
return err.handler(ctx); | ||
} | ||
// 执行全局异常处理 | ||
// 执行自定义全局异常处理 | ||
const message = (err.message).includes('"') ? (err.message).replaceAll('"', '\\"') : err.message; | ||
if (globalErrorHandler) { | ||
return new globalErrorHandler(message, err.code ?? 1, err.status || 500).handler(ctx); | ||
const ins = new globalErrorHandler(message, err.code ?? 1, err.status || 500, err.stack, span); | ||
if (ins.handler) { | ||
return ins.handler(ctx); | ||
} | ||
} | ||
// 使用默认异常处理 | ||
return new koatty_exception.Exception(message, err.code ?? 1, err.status || 500).default(ctx); | ||
return new koatty_exception.Exception(message, err.code ?? 1, err.status || 500, err.stack, span).handler(ctx); | ||
} | ||
@@ -442,3 +438,3 @@ | ||
* @LastEditors: Please set LastEditors | ||
* @LastEditTime: 2024-01-16 08:03:53 | ||
* @LastEditTime: 2024-01-21 12:34:46 | ||
* @License: BSD (3-Clause) | ||
@@ -445,0 +441,0 @@ * @Copyright (c) - <richenlin(at)gmail.com> |
{ | ||
"name": "koatty_trace", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"description": "Full link tracking and error interception for koatty.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# koatty_trace | ||
Full link tracking and error interception for koatty. |
{ | ||
"name": "koatty_trace", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"description": "Full link tracking and error interception for koatty.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# koatty_trace | ||
Full link tracking and error interception for koatty. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54345
1203