@ecdt/logger 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,6 +58,25 @@ app.get("/throw-error", (_req, res) => {
58
58
  throw new Error('throw error example');
59
59
  })
60
60
 
61
+ // Simula um erro do Axios (isAxiosError)
62
+ app.get("/axios-error", (_req, res) => {
63
+ const axiosError = new Error('Request failed with status code 503');
64
+ axiosError.isAxiosError = true;
65
+ axiosError.config = {
66
+ method: 'get',
67
+ baseURL: 'https://api.exemplo.com',
68
+ url: '/usuarios',
69
+ headers: { 'Content-Type': 'application/json' },
70
+ };
71
+ axiosError.response = {
72
+ status: 503,
73
+ statusText: 'Service Unavailable',
74
+ headers: { 'content-type': 'application/json' },
75
+ data: { error: 'Serviço temporariamente indisponível' },
76
+ };
77
+ throw axiosError;
78
+ })
79
+
61
80
  // Error handler (sempre por último, após as rotas)
62
81
  app.use(createErrorCapture());
63
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecdt/logger",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Logger padronização de microsserviços da Econodata",
5
5
  "type": "commonjs",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -26,6 +26,7 @@ function createErrorCapture() {
26
26
  message: err?.message,
27
27
  stack: err?.stack
28
28
  };
29
+
29
30
  if (err?.isAxiosError) {
30
31
  const responseData = err.response?.data;
31
32
  const dataSummary = typeof responseData === 'string' && responseData.length > 300
@@ -19,7 +19,8 @@ function formatLog(tokens, req, res, options = {}){
19
19
  if(_status >= 500 && res.error && res.error.stack && normalized.includeStackErrors5xx) {
20
20
  normalized.extraFields.error = {
21
21
  message: res.error.message ?? '',
22
- stack: res.error.stack
22
+ stack: res.error.stack,
23
+ details: res.errorDetails
23
24
  }
24
25
  }
25
26