From 277fb92f9eb5bfafb83a66ff6567aa329cefcc56 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Tue, 14 Jan 2020 18:38:43 -0500 Subject: [PATCH] abi-gen: exit when black fails to parse Python Note: this is not the same case as when the black executable can't be found; that case is still just a (non-fatal) warning. --- packages/abi-gen/src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 2bef521792..be65fa6475 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -277,10 +277,16 @@ for (const abiFileName of abiFileNames) { // use command-line tool black to reformat, if its available try { execSync(`black --line-length 79 ${outFilePath}`); - } catch { - logUtils.warn( - 'Failed to reformat generated Python with black. Do you have it installed? Proceeding anyways...', - ); + } catch (e) { + const BLACK_RC_CANNOT_PARSE = 123; // empirical black exit code + if (e.status === BLACK_RC_CANNOT_PARSE) { + logUtils.warn( + 'Failed to reformat generated Python with black. Exception thrown by execSync("black ...") follows.', + ); + throw e; + } else { + logUtils.warn('Failed to invoke black. Do you have it installed? Proceeding anyways...'); + } } }