Unverified Commit 25dd8684 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

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

parent df981455
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment