edf2csv 0.8.10 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/convert/run.js +35 -13
- package/dist/convert/run.js.map +1 -1
- package/dist/edf/header.js +23 -2
- package/dist/edf/header.js.map +1 -1
- package/dist/edf/reader.js +3 -3
- package/dist/edf/reader.js.map +1 -1
- package/package.json +1 -1
package/dist/convert/run.js
CHANGED
|
@@ -351,7 +351,7 @@ async function prepareOutputDir(dir, force) {
|
|
|
351
351
|
if (info && !info.isDirectory()) {
|
|
352
352
|
throw new ConversionError('OUTPUT_UNWRITABLE', `Cannot create "${dir}": "${parent}" is a file, not a directory.`, 'Choose a destination whose parent directories are directories, with --out.');
|
|
353
353
|
}
|
|
354
|
-
throw new ConversionError('OUTPUT_UNWRITABLE', `Cannot create "${dir}": ${describeFsError(cause)}.`,
|
|
354
|
+
throw new ConversionError('OUTPUT_UNWRITABLE', `Cannot create "${dir}": ${describeFsError(cause)}.`, createHint(cause));
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
let claimed = true;
|
|
@@ -360,7 +360,7 @@ async function prepareOutputDir(dir, force) {
|
|
|
360
360
|
}
|
|
361
361
|
catch (cause) {
|
|
362
362
|
if (cause.code !== 'EEXIST') {
|
|
363
|
-
throw new ConversionError('OUTPUT_UNWRITABLE', `Cannot create "${dir}": ${describeFsError(cause)}.`,
|
|
363
|
+
throw new ConversionError('OUTPUT_UNWRITABLE', `Cannot create "${dir}": ${describeFsError(cause)}.`, createHint(cause));
|
|
364
364
|
}
|
|
365
365
|
claimed = false;
|
|
366
366
|
}
|
|
@@ -1204,31 +1204,53 @@ function writeHint(cause, toStdout = false) {
|
|
|
1204
1204
|
const preamble = toStdout
|
|
1205
1205
|
? 'What reached stdout before it failed is incomplete and should not be used. '
|
|
1206
1206
|
: 'The files written so far are incomplete and should not be used. ';
|
|
1207
|
-
|
|
1207
|
+
return (preamble +
|
|
1208
|
+
destinationAdvice(cause, toStdout ? 'redirect it somewhere else' : 'choose another with --out', toStdout ? 'redirect it somewhere shorter' : 'choose a shorter destination with --out'));
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* The same question asked before anything has been written: the output directory could not be
|
|
1212
|
+
* created.
|
|
1213
|
+
*
|
|
1214
|
+
* Both raisings carried one sentence for every errno — "Check the path exists and that you
|
|
1215
|
+
* have permission to write there" — which is the shape `writeHint` above was written to
|
|
1216
|
+
* replace, in the words of its own docstring: "Wrong advice is worse than none: it sends
|
|
1217
|
+
* someone to check `df` on a disk that is fine, and the thing that is actually wrong stays
|
|
1218
|
+
* unexamined." A full disk, a read-only volume and a path past the filesystem's length limit
|
|
1219
|
+
* all got advice about a path that exists and a permission that is not the problem, two lines
|
|
1220
|
+
* under a message where `describeFsError` had already named the cause exactly.
|
|
1221
|
+
*
|
|
1222
|
+
* No preamble, because nothing has been written yet — which is the only thing that differs
|
|
1223
|
+
* between the two, so the sentences themselves are shared rather than copied.
|
|
1224
|
+
*/
|
|
1225
|
+
function createHint(cause) {
|
|
1226
|
+
return destinationAdvice(cause, 'choose another with --out', 'choose a shorter destination with --out');
|
|
1227
|
+
}
|
|
1228
|
+
/** The sentence an errno earns, with the two phrases that name where "somewhere else" is. */
|
|
1229
|
+
function destinationAdvice(cause, elsewhere, shorter) {
|
|
1208
1230
|
const code = cause?.code;
|
|
1209
1231
|
switch (code) {
|
|
1210
1232
|
case 'ENOSPC':
|
|
1211
|
-
return
|
|
1233
|
+
return `The destination is out of space; free some up or ${elsewhere}.`;
|
|
1212
1234
|
case 'EDQUOT':
|
|
1213
|
-
return
|
|
1235
|
+
return `You are over your disk quota on this filesystem; ${elsewhere}.`;
|
|
1214
1236
|
case 'EACCES':
|
|
1215
1237
|
case 'EPERM':
|
|
1216
|
-
return
|
|
1238
|
+
return `You do not have permission to write there; ${elsewhere}.`;
|
|
1217
1239
|
case 'EROFS':
|
|
1218
|
-
return
|
|
1240
|
+
return `That filesystem is mounted read-only; ${elsewhere}.`;
|
|
1219
1241
|
case 'EISDIR':
|
|
1220
|
-
return
|
|
1242
|
+
return `A directory is sitting where that file belongs; remove or rename it, or ${elsewhere}.`;
|
|
1221
1243
|
case 'ENOENT':
|
|
1222
|
-
return
|
|
1244
|
+
return `Part of that path no longer exists; make sure nothing is removing it while the conversion runs.`;
|
|
1223
1245
|
case 'ENAMETOOLONG':
|
|
1224
|
-
return
|
|
1246
|
+
return `That path is longer than the filesystem allows; ${shorter}.`;
|
|
1225
1247
|
case 'EMFILE':
|
|
1226
1248
|
case 'ENFILE':
|
|
1227
|
-
return
|
|
1249
|
+
return `Too many files are open; a recording with many sampling rates opens one output file per rate, so --channels narrows it.`;
|
|
1228
1250
|
case 'EPIPE':
|
|
1229
|
-
return
|
|
1251
|
+
return 'Whatever was reading the output closed it before the conversion finished.';
|
|
1230
1252
|
default:
|
|
1231
|
-
return
|
|
1253
|
+
return 'Check the destination and run the conversion again.';
|
|
1232
1254
|
}
|
|
1233
1255
|
}
|
|
1234
1256
|
/**
|