Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ class CompiledProtodef {
const buffer = Buffer.allocUnsafe(length)
tryCatch(() => this.write(packet, buffer, 0, type),
(e) => {
e.message = `Write error for ${e.field} : ${e.message}`
let packetStr = ''
try { packetStr = JSON.stringify(packet) } catch (err) { try { packetStr = String(packet) } catch (err) {} }
e.message = `Write error for ${e.field} in ${packetStr} : ${e.message}`
throw e
})
return buffer
Expand Down
6 changes: 4 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ function addErrorField (e, field) {
throw e
}

function tryCatch (tryfn, catchfn) {
try { return tryfn() } catch (e) { catchfn(e) }
function tryCatch(tryfn, catchfn) {
const oldLimit = Error.stackTraceLimit
Error.stackTraceLimit = Math.max(40, oldLimit)
try { return tryfn() } catch (e) { catchfn(e) } finally { Error.stackTraceLimit = oldLimit }
}

function tryDoc (tryfn, field) {
Expand Down