[flutter_tools] add 483 to non-recoverable errors (#73579)

This commit is contained in:
Jonah Williams
2021-01-08 11:56:13 -08:00
committed by GitHub
parent df98145548
commit 25dd8684b1
2 changed files with 31 additions and 0 deletions

View File

@@ -692,6 +692,8 @@ void _handleWindowsException(Exception e, String message, int errorCode) {
const int kDeviceFull = 112;
const int kUserMappedSectionOpened = 1224;
const int kAccessDenied = 5;
const int kFatalDeviceHardwareError = 483;
// Catch errors and bail when:
String errorMessage;
switch (errorCode) {
@@ -714,6 +716,11 @@ void _handleWindowsException(Exception e, String message, int errorCode) {
'Do you have an antivirus program running? '
'Try disabling your antivirus program and try again.';
break;
case kFatalDeviceHardwareError:
errorMessage =
'$message. There is a problem with the device driver '
'that this file or directory is stored on.';
break;
default:
// Caller must rethrow the exception.
break;

View File

@@ -173,6 +173,7 @@ void main() {
const int kDeviceFull = 112;
const int kUserMappedSectionOpened = 1224;
const int kUserPermissionDenied = 5;
const int kFatalDeviceHardwareError = 483;
MockFileSystem mockFileSystem;
ErrorHandlingFileSystem fs;
@@ -271,6 +272,29 @@ void main() {
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when the device driver has a fatal error', () async {
setupWriteMocks(
mockFileSystem: mockFileSystem,
fs: fs,
errorCode: kFatalDeviceHardwareError,
);
final File file = fs.file('file');
const String expectedMessage = 'There is a problem with the device driver '
'that this file or directory is stored on';
expect(() async => await file.writeAsBytes(<int>[0]),
throwsToolExit(message: expectedMessage));
expect(() async => await file.writeAsString(''),
throwsToolExit(message: expectedMessage));
expect(() => file.writeAsBytesSync(<int>[0]),
throwsToolExit(message: expectedMessage));
expect(() => file.writeAsStringSync(''),
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when creating a temporary dir on a full device', () async {
setupDirectoryMocks(
mockFileSystem: mockFileSystem,