Skip to content

Commit

Permalink
"Error: Cannot send non-string log to report portal!" is thrown in ma…
Browse files Browse the repository at this point in the history
…ny cases (#25)
  • Loading branch information
danitseitlin authored Mar 22, 2021
1 parent b3d91e1 commit 5bcf351
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class API {
async sendLog (projectName, options) {
try {
if(typeof options.message !== 'string')
throw new Error(`Cannot send non-string log to report portal!\n${options.message}`)
options.message = `${options.message}`;
if (options.file) {
const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
const fullPath = options.file.path;
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ exports['default'] = () => {
async reportLogs(testId, level, message, time, attachment) {
if(message !== undefined) {
const isJSON = this.reporter.client.isJSON(message) || Array.isArray(message);
//If the log is a stacktrace, and we want to focus on printing the error message itself.
if(isJSON && JSON.parse(message).errMsg !== undefined) message = JSON.parse(message).errMsg;
//If the log is a JS Object
else if(isJSON) message = JSON.parse(message)
message = this.reporter.client.isJSON(message) ? JSON.stringify(message): message
}
Expand Down

0 comments on commit 5bcf351

Please sign in to comment.