1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-13 18:16:19 +02:00

add 3 different errors for preview failure

This commit is contained in:
Kushagra Gour
2017-07-16 01:39:48 +05:30
parent 35a8ad71d7
commit 21646c20f9

View File

@ -966,9 +966,10 @@ customEditorFontInput
function writeFile(name, blob, cb) {
var fileWritten = false;
function errorHandler() {
function getErrorHandler(type) {
return function() {
utils.log(arguments);
trackEvent('fn', 'error', 'writeFile');
trackEvent('fn', 'error', type);
// When there are too many write errors, show a message.
writeFile.errorCount = (writeFile.errorCount || 0) + 1;
if (writeFile.errorCount === 4) {
@ -979,6 +980,7 @@ customEditorFontInput
trackEvent('ui', 'writeFileMessageSeen');
}, 1000);
}
};
}
// utils.log('writing file ', name);
@ -990,7 +992,7 @@ customEditorFontInput
name,
{ create: true },
function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
fileEntry.createWriter(fileWriter => {
function onWriteComplete() {
if (fileWritten) {
// utils.log('file written ', name);
@ -1006,12 +1008,12 @@ customEditorFontInput
// Empty the file contents
fileWriter.truncate(0);
// utils.log('truncating file ', name);
}, errorHandler);
}, getErrorHandler('createWriterFail'));
},
errorHandler
getErrorHandler('getFileFail')
);
},
errorHandler
getErrorHandler('webkitRequestFileSystemFail')
);
}