javonet-nodejs-sdk 2.5.20 → 2.6.1

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.
@@ -6,21 +6,34 @@ import { ExceptionType } from '../ExceptionType.js'
6
6
  class ExceptionSerializer {
7
7
  static serializeException(exception, command) {
8
8
  let exceptionCommand = new Command(RuntimeName.Nodejs, CommandType.Exception, [])
9
- exceptionCommand = exceptionCommand.addArgToPayload(this.getExceptionCode(exception))
10
- exceptionCommand = exceptionCommand.addArgToPayload(command.toString())
11
- exceptionCommand = exceptionCommand.addArgToPayload(exception.name)
12
- exceptionCommand = exceptionCommand.addArgToPayload(exception.message)
13
9
 
14
10
  let stackClasses = []
15
11
  let stackMethods = []
16
12
  let stackLines = []
17
13
  let stackFiles = []
18
14
 
19
- this.serializeStackTrace(exception, stackClasses, stackMethods, stackLines, stackFiles)
20
- exceptionCommand = exceptionCommand.addArgToPayload(stackClasses.join('|'))
21
- exceptionCommand = exceptionCommand.addArgToPayload(stackMethods.join('|'))
22
- exceptionCommand = exceptionCommand.addArgToPayload(stackLines.join('|'))
23
- exceptionCommand = exceptionCommand.addArgToPayload(stackFiles.join('|'))
15
+ try {
16
+ this.serializeStackTrace(exception, stackClasses, stackMethods, stackLines, stackFiles)
17
+
18
+ exceptionCommand = exceptionCommand.addArgToPayload(this.getExceptionCode(exception))
19
+ exceptionCommand = exceptionCommand.addArgToPayload(command ? command.toString() : 'Command is null')
20
+ exceptionCommand = exceptionCommand.addArgToPayload(exception.name)
21
+ exceptionCommand = exceptionCommand.addArgToPayload(exception.message)
22
+ exceptionCommand = exceptionCommand.addArgToPayload(stackClasses.join('|'))
23
+ exceptionCommand = exceptionCommand.addArgToPayload(stackMethods.join('|'))
24
+ exceptionCommand = exceptionCommand.addArgToPayload(stackLines.join('|'))
25
+ exceptionCommand = exceptionCommand.addArgToPayload(stackFiles.join('|'))
26
+ } catch (e) {
27
+ exceptionCommand = new Command(RuntimeName.Nodejs, CommandType.Exception, [])
28
+ exceptionCommand = exceptionCommand.addArgToPayload(this.getExceptionCode(e))
29
+ exceptionCommand = exceptionCommand.addArgToPayload(command ? command.toString() : 'Command is null')
30
+ exceptionCommand = exceptionCommand.addArgToPayload('Node.js Exception Serialization Error')
31
+ exceptionCommand = exceptionCommand.addArgToPayload(e.message)
32
+ exceptionCommand = exceptionCommand.addArgToPayload('ExceptionSerializer')
33
+ exceptionCommand = exceptionCommand.addArgToPayload('serializeException')
34
+ exceptionCommand = exceptionCommand.addArgToPayload('unknown')
35
+ exceptionCommand = exceptionCommand.addArgToPayload('ExceptionSerializer.js')
36
+ }
24
37
 
25
38
  return exceptionCommand
26
39
  }
@@ -39,23 +52,40 @@ class ExceptionSerializer {
39
52
  }
40
53
 
41
54
  static serializeStackTrace(exception, stackClasses, stackMethods, stackLines, stackFiles) {
55
+ if (!exception || typeof exception.stack !== 'string') {
56
+ return
57
+ }
42
58
  const stackTrace = exception.stack.split('\n').slice(1)
43
59
 
44
- for (let i = 0; i < stackTrace.length; i++) {
45
- const parts = stackTrace[i].trim().match(/at\s(.*)\s\((.*):(\d+):(\d+)\)/)
60
+ for (const line of stackTrace) {
61
+ const trimmedLine = line.trim()
62
+ if (trimmedLine.includes('Javonet.Node.js')) {
63
+ continue
64
+ }
65
+
66
+ // Pattern for: at Class.method (file:line:column) or at functionName (file:line:column)
67
+ let parts = trimmedLine.match(/at\s+(.*?)\s+\((.*?):(\d+):\d+\)/)
46
68
  if (parts) {
47
- stackClasses.push(parts[1])
48
- stackMethods.push('unknown')
49
- stackLines.push(parts[3])
50
- stackFiles.push(parts[2])
51
- } else {
52
- const parts = stackTrace[i].trim().match(/at\s(.*):(\d+):(\d+)/)
53
- if (parts) {
69
+ const classAndMethod = parts[1].split('.')
70
+ if (classAndMethod.length > 1) {
71
+ stackClasses.push(classAndMethod[0])
72
+ stackMethods.push(classAndMethod.slice(1).join('.'))
73
+ } else {
54
74
  stackClasses.push('unknown')
55
- stackMethods.push('unknown')
56
- stackLines.push(parts[2])
57
- stackFiles.push(parts[1])
75
+ stackMethods.push(parts[1])
58
76
  }
77
+ stackFiles.push(parts[2])
78
+ stackLines.push(parts[3])
79
+ continue
80
+ }
81
+
82
+ // Pattern for: at file:line:column (often for anonymous functions or top-level scripts)
83
+ parts = trimmedLine.match(/at\s+(.*?):(\d+):\d+/)
84
+ if (parts) {
85
+ stackClasses.push('unknown')
86
+ stackMethods.push('unknown')
87
+ stackFiles.push(parts[1])
88
+ stackLines.push(parts[2])
59
89
  }
60
90
  }
61
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javonet-nodejs-sdk",
3
- "version": "2.5.20",
3
+ "version": "2.6.1",
4
4
  "description": "Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/",
5
5
  "keywords": [],
6
6
  "author": "SdNCenter Sp. z o. o.",
@@ -70,6 +70,7 @@
70
70
  "eslint-config-prettier": "^9.1.0",
71
71
  "eslint-plugin-jest": "^28.9.0",
72
72
  "eslint-plugin-prettier": "^5.2.1",
73
+ "fs-extra": "^11.3.0",
73
74
  "husky": "^8.0.0",
74
75
  "ignore": "^6.0.2",
75
76
  "jest": "^29.7.0",
@@ -87,7 +88,6 @@
87
88
  "peerDependencies": {
88
89
  "crypto": "^1.0.1",
89
90
  "dns": "^0.2.2",
90
- "fs-extra": "^11.2.0",
91
91
  "ws": "^8.0.0"
92
92
  },
93
93
  "peerDependenciesMeta": {