🎨 Improve error message
This commit is contained in:
parent
2b840abc9a
commit
c814f4d1ff
1 changed files with 2 additions and 2 deletions
|
@ -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}.`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue