mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-08 01:48:32 +00:00
fix: Handle gracefully when trying to detect invalid sketch name error and folder is missing on filesystem (#1616)
- feat: generalized Node.js error handling
- Gracefully handle when the sketch folder has been deleted
- feat: spare detecting invalid sketch name error
- The invalid sketch name detection requires at least one extra FS access.
Do not try to detect the invalid sketch name error, but use the original
`NotFound` from the CLI.
- fix: typo
Closes #1596
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
SHOW_PLOTTER_WINDOW,
|
||||
} from '../../common/ipc-communication';
|
||||
import isValidPath = require('is-valid-path');
|
||||
import { ErrnoException } from '../../node/utils/errors';
|
||||
|
||||
app.commandLine.appendSwitch('disable-http-cache');
|
||||
|
||||
@@ -172,7 +173,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
|
||||
try {
|
||||
stats = await fs.stat(path);
|
||||
} catch (err) {
|
||||
if ('code' in err && err.code === 'ENOENT') {
|
||||
if (ErrnoException.isENOENT(err)) {
|
||||
return undefined;
|
||||
}
|
||||
throw err;
|
||||
@@ -215,7 +216,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
|
||||
const resolved = await fs.realpath(resolve(cwd, maybePath));
|
||||
return resolved;
|
||||
} catch (err) {
|
||||
if ('code' in err && err.code === 'ENOENT') {
|
||||
if (ErrnoException.isENOENT(err)) {
|
||||
return undefined;
|
||||
}
|
||||
throw err;
|
||||
|
||||
Reference in New Issue
Block a user