From 87f1edbff73425e23e4d2b5141fb47ddfd8bec26 Mon Sep 17 00:00:00 2001 From: TINGAUD Frederic Date: Wed, 22 Nov 2023 15:07:51 +0100 Subject: [PATCH] Apply error display for BB --- src/libbuild.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libbuild.js b/src/libbuild.js index 30e0880..a5ad53a 100644 --- a/src/libbuild.js +++ b/src/libbuild.js @@ -12,6 +12,13 @@ const ALLOW_CONTAINER_DOWNLOAD = process.env.ALLOW_CONTAINER_DOWNLOAD; const WRITE_PATH = '/data'; +class BenchError extends Error{ + constructor(message) { + super(message); + this.name = "BenchError"; + } +} + async function listContainers() { AVAILABLE_CONTAINERS = []; await docker.listContainers(AVAILABLE_CONTAINERS); @@ -53,7 +60,7 @@ function execute(fileName, request, protocolVersion, force) { console.timeEnd(fileName); console.log('Bench failed ' + fileName); exec("./kill-docker " + fileName); - reject("\u001b[0m\u001b[0;1;31mError or timeout\u001b[0m\u001b[1m
" + stdout + "
" + stderr); + reject(new BenchError("\u001b[0m\u001b[0;1;31mError or timeout\u001b[0m\u001b[1m
" + stdout + "
" + stderr)); } else { console.timeEnd(fileName); console.log('Bench done ' + fileName + (stderr.indexOf('cached results') > -1 ? ' from cache' : '')); @@ -120,8 +127,12 @@ async function benchmarkOneBuild(tab, protocolVersion, force) { await tools.write(fileName + '.opt', optionsToString(tab, protocolVersion)); return await execute(fileName, tab, protocolVersion, force); } catch (e) { - console.log(e); - return Promise.reject('Unexpected error while processing the benchmark, please contact the website owner'); + if (e instanceof BenchError) { + return { stdout: e.message }; + } else { + console.log(e); + return Promise.reject('Unexpected error while processing the benchmark, please contact the website owner'); + } } }