Skip to content

Commit

Permalink
Fixes unhandled rejection in clasp logs (#129)
Browse files Browse the repository at this point in the history
Does this by catching the error and loggin an appropriate message for the user.
  • Loading branch information
campionfellin authored and grant committed Apr 23, 2018
1 parent 1a413d7 commit 5fd6aa2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Forgot ${PROJECT_NAME} commands? Get help:\n ${PROJECT_NAME} --help`,
FS_FILE_WRITE: 'Could not write file.',
LOGGED_IN: `You seem to already be logged in. Did you mean to 'logout'?`,
LOGGED_OUT: `\nCommand failed. Please login. (${PROJECT_NAME} login)`,
LOGS_UNAVAILABLE: 'StackDriver logs are getting ready, try again soon.',
OFFLINE: 'Error: Looks like you are offline.',
ONE_DEPLOYMENT_CREATE: 'Currently just one deployment can be created at a time.',
NO_FUNCTION_NAME: 'N/A',
Expand Down Expand Up @@ -1071,9 +1072,10 @@ commander
let coloredSeverity = ({
ERROR: chalk.red(severity),
INFO: chalk.blue(severity),
DEBUG: chalk.yellow(severity)
DEBUG: chalk.yellow(severity),
NOTICE: chalk.magenta(severity)
})[severity] || severity;
coloredSeverity = String(coloredSeverity).padEnd(15);
coloredSeverity = String(coloredSeverity).padEnd(20);
console.log(`${coloredSeverity} ${timestamp} ${functionName} ${payloadData}`);
}
}
Expand All @@ -1092,7 +1094,9 @@ commander
const logger = new logging({
projectId,
});
return logger.getEntries().then(printLogs);
return logger.getEntries().then(printLogs).catch((err) => {
console.error(ERROR.LOGS_UNAVAILABLE);
});
});
});

Expand Down

0 comments on commit 5fd6aa2

Please sign in to comment.