Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix temp file open error handling (#64)
- Fix error handling when temporary fail cannot be opened (e.g. because of access error). `catch` doesn't work since `open` always returns child process reference when `wait: false`. It should address #64 - Add `sme-result-` prefix to the temporary file. - Add 2 app errors: `CannotCreateTempFile` and `CannotOpenTempFile` in order to separate creating and opening an temporary HTML file - Update dependencies - Prepare 2.0.0 version
- Loading branch information
1 parent
e1ec282
commit db62a35
Showing
9 changed files
with
145 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
exports['app-error getErrorMessage should create message for \'CannotCreateTempFile\' 1'] = ` | ||
Unable to create a temporary HTML file | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'CannotOpenTempFile\' 1'] = ` | ||
Unable to open web browser. The system cannot find the file ?C:\\foo.htm | ||
Either run with --html, --json, --tsv, --file, or view HTML for the visualization at: | ||
C:\\foo.htm | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'CannotSaveFile\' 1'] = ` | ||
Unable to save HTML to file | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'NoBundles\' 1'] = ` | ||
No file(s) provided | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'NoSourceMap\' 1'] = ` | ||
Unable to find a source map. | ||
See https://github.com/danvk/source-map-explorer/blob/master/README.md#generating-source-maps | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'OneSourceSourceMap\' 1'] = ` | ||
Your source map only contains one source (foo.min.js). | ||
This can happen if you use browserify+uglifyjs, for example, and don't set the --in-source-map flag to uglify. | ||
See https://github.com/danvk/source-map-explorer/blob/master/README.md#generating-source-maps | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'UnknownCode\' 1'] = ` | ||
Unknown error | ||
` | ||
|
||
exports['app-error getErrorMessage should create message for \'UnmappedBytes\' 1'] = ` | ||
Unable to map 70/100 bytes (70.00%) | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import snapshot from '@smpx/snap-shot-it'; | ||
|
||
import { getErrorMessage } from '../src/app-error'; | ||
|
||
describe('app-error', function() { | ||
describe('getErrorMessage', function() { | ||
const tests = [ | ||
{ code: 'NoBundles' }, | ||
{ code: 'NoSourceMap' }, | ||
{ code: 'OneSourceSourceMap', filename: 'foo.min.js' }, | ||
{ code: 'UnmappedBytes', totalBytes: 100, unmappedBytes: 70 }, | ||
{ code: 'CannotSaveFile' }, | ||
{ code: 'CannotCreateTempFile' }, | ||
{ | ||
code: 'CannotOpenTempFile', | ||
error: Buffer.from('The system cannot find the file ?C:\\foo.htm'), | ||
tempFile: 'C:\\foo.htm', | ||
}, | ||
{ code: 'UnknownCode' }, | ||
]; | ||
|
||
tests.forEach(function(context) { | ||
it(`should create message for '${context.code}'`, function() { | ||
snapshot(getErrorMessage(context as any)); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters