Skip to content

Commit

Permalink
Merge pull request #573 from oceanprotocol/sendto-try-catch
Browse files Browse the repository at this point in the history
another try/catch
  • Loading branch information
paulo-ocean authored Jul 31, 2024
2 parents dd241a9 + 2e12af9 commit 1c4bd0b
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/components/P2P/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,33 @@ export class OceanP2P extends EventEmitter {
return response
}

response.stream = stream
pipe(
// Source data
[uint8ArrayFromString(message)],
// Write to the stream, and pass its output to the next function
stream,
// this is the anayze function
// doubler as any,
// Sink function
sink
)
if (stream) {
response.stream = stream
try {
pipe(
// Source data
[uint8ArrayFromString(message)],
// Write to the stream, and pass its output to the next function
stream,
// this is the anayze function
// doubler as any,
// Sink function
sink
)
} catch (err) {
P2P_LOGGER.log(
LOG_LEVELS_STR.LEVEL_ERROR,
`Unable to send P2P message: ${err.message}`
)
response.status.httpStatus = 404
response.status.error = err.message
}
} else {
response.status.httpStatus = 404
response.status.error = 'Unable to get remote P2P stream (null)'
P2P_LOGGER.log(LOG_LEVELS_STR.LEVEL_ERROR, response.status.error)
}

return response
}

Expand Down

0 comments on commit 1c4bd0b

Please sign in to comment.