🎨 Improve error message

This commit is contained in:
C-3PO 2018-11-16 05:48:28 +01:00
parent 2b840abc9a
commit c814f4d1ff
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -13,7 +13,7 @@ const CHECK_INTERVAL = 15;
*/ */
export default function downloadWithCurl({ host, path, tempFileName }: {host: string, path: string, tempFileName: string}): Promise<string> { export default function downloadWithCurl({ host, path, tempFileName }: {host: string, path: string, tempFileName: string}): Promise<string> {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
const url = `http://${host}${(path.substr(0, 1) === '/' ? '' : '/')}${path}`; const url = `http://${host}${(path[0] === '/' ? '' : '/')}${path}`;
const parameters: string[] = [ const parameters: string[] = [
//... //...
@ -36,7 +36,7 @@ export default function downloadWithCurl({ host, path, tempFileName }: {host: st
if (code === 0) { if (code === 0) {
resolve(tempFileName); resolve(tempFileName);
} else if (code === 28) { } else if (code === 28) {
reject(`Download speed too slow, will restart "${url}".`); reject(`Download speed too slow, restarting "${path.includes('/') ? path.substr(path.lastIndexOf('/')) : path}".`);
} else { } else {
reject(`Error in process:\n> curl ${parameters.join(' ')}\nNon-zero exit code ${code}.`); reject(`Error in process:\n> curl ${parameters.join(' ')}\nNon-zero exit code ${code}.`);
} }