From e47dcc1b37815a4bf0c7661aabd45cb0299197c8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 27 Feb 2020 11:29:52 -0600 Subject: [PATCH] Handle errors when stringifying errors in uploads (#1008) Should hopefully fix a failed publication at https://github.com/bytecodealliance/wasmtime/runs/471153746. I really am truly bad at JS. --- .github/actions/github-release/main.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/actions/github-release/main.js b/.github/actions/github-release/main.js index 571a2978b5..567fe3967f 100644 --- a/.github/actions/github-release/main.js +++ b/.github/actions/github-release/main.js @@ -94,17 +94,24 @@ async function run() { } catch (e) { if (i === retries - 1) throw e; - console.log("ERROR: ", JSON.stringify(e, null, 2)); - console.log("ERROR: ", e.message); - console.log(e.stack); + logError(e); console.log("RETRYING after 10s"); await sleep(10000) } } } +function logError(e) { + console.log("ERROR: ", e.message); + try { + console.log(JSON.stringify(e, null, 2)); + } catch (e) { + // ignore json errors for now + } + console.log(e.stack); +} + run().catch(err => { - console.log("ERROR: ", JSON.stringify(err, null, 2)); + logError(err); core.setFailed(err.message); - console.log(err.stack); });