OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "NSError+ChromeInstallerAdditions.h" | 5 #import "NSError+ChromeInstallerAdditions.h" |
6 | 6 |
7 @implementation NSError (ChromeInstallerAdditions) | 7 @implementation NSError (ChromeInstallerAdditions) |
8 // Creates a custom error object to be used as the popup alert that the user | |
9 // will be shown. | |
10 + (NSError*)errorForAlerts:(NSString*)message | 8 + (NSError*)errorForAlerts:(NSString*)message |
11 withDescription:(NSString*)description | 9 withDescription:(NSString*)description |
12 isRecoverable:(BOOL)recoverable { | 10 isRecoverable:(BOOL)recoverable { |
13 NSArray* options = @[]; | 11 NSArray* options = @[]; |
14 if (recoverable) { | 12 if (recoverable) { |
15 options = @[ @"Try Again", @"Quit" ]; | 13 options = @[ @"Try Again", @"Quit" ]; |
16 } else { | 14 } else { |
17 options = @[ @"Quit" ]; | 15 options = @[ @"Quit" ]; |
18 } | 16 } |
19 | 17 |
20 NSDictionary* errorContents = @{ | 18 NSDictionary* errorContents = @{ |
21 NSLocalizedDescriptionKey : NSLocalizedString(message, nil), | 19 NSLocalizedDescriptionKey : NSLocalizedString(message, nil), |
22 NSLocalizedRecoveryOptionsErrorKey : options, | 20 NSLocalizedRecoveryOptionsErrorKey : options, |
23 NSLocalizedRecoverySuggestionErrorKey : NSLocalizedString(description, nil) | 21 NSLocalizedRecoverySuggestionErrorKey : NSLocalizedString(description, nil) |
24 }; | 22 }; |
25 return [NSError errorWithDomain:@"ChromeErrorDomain" | 23 return [NSError errorWithDomain:@"ChromeErrorDomain" |
26 code:-1 | 24 code:-1 |
27 userInfo:errorContents]; | 25 userInfo:errorContents]; |
28 } | 26 } |
29 @end | 27 @end |
OLD | NEW |