Changeset 1767


Ignore:
Timestamp:
2/8/2010 7:09:55 AM (2 years ago)
Author:
lowjoel
Message:

Do not localise exceptions which aren't meant to be seen by the user. User-visible exceptions will be dealt with in a separate ticket. Do not throw exceptions to indicate handleable errors (notably, when erasing unused space without administrator permissions) Addresses #275: Code Review

Location:
branches/eraser6/CodeReview
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/ErasureMethods/FirstLast16KB.cs

    r1745 r1767  
    110110            //less. 
    111111            if (erasureLength != long.MaxValue) 
    112                 throw new ArgumentException(S._("The amount of data erased should not be " + 
    113                     "limited, since this is a self-limiting erasure method.")); 
     112                throw new ArgumentException("The amount of data erased should not be " + 
     113                    "limited, since this is a self-limiting erasure method."); 
    114114 
    115115            //If the target stream is shorter than or equal to 32kb, just forward it to 
  • branches/eraser6/CodeReview/Eraser.Manager/DirectExecutor.cs

    r1765 r1767  
    263263                                    EraseFilesystemObject(task, fileSystemObjectTarget); 
    264264                                else 
    265                                     throw new ArgumentException(S._("Unknown erasure target.")); 
     265                                    throw new ArgumentException("Unknown erasure target."); 
    266266                            } 
    267267                            catch (FatalException) 
     
    341341                    Environment.OSVersion.Version >= new Version(6, 0)) 
    342342                { 
    343                     throw new UnauthorizedAccessException(S._("The program does not have the " + 
    344                         "required permissions to erase the unused space on disk. Run the program " + 
    345                         "as an administrator and retry the operation.")); 
     343                    task.Log.LastSessionEntries.Add(new LogEntry(S._("The program does not have " + 
     344                        "the required permissions to erase the unused space on disk. Run the " + 
     345                        "program as an administrator and retry the operation."), LogLevel.Error)); 
    346346                } 
    347347                else 
    348                     throw new UnauthorizedAccessException(S._("The program does not have the " + 
    349                         "required permissions to erase the unused space on disk.")); 
     348                { 
     349                    task.Log.LastSessionEntries.Add(new LogEntry(S._("The program does not have " + 
     350                        "the required permissions to erase the unused space on disk"), 
     351                        LogLevel.Error)); 
     352                } 
    350353            } 
    351354 
  • branches/eraser6/CodeReview/Eraser.Manager/Method.cs

    r1681 r1767  
    378378            public override long CalculateEraseDataSize(ICollection<string> paths, long targetSize) 
    379379            { 
    380                 throw new InvalidOperationException(S._("The DefaultMethod class should never " + 
    381                     "be used and should instead be replaced before execution!")); 
     380                throw new InvalidOperationException("The DefaultMethod class should never " + 
     381                    "be used and should instead be replaced before execution!"); 
    382382            } 
    383383 
     
    385385                ErasureMethodProgressFunction callback) 
    386386            { 
    387                 throw new InvalidOperationException(S._("The DefaultMethod class should never " + 
    388                     "be used and should instead be replaced before execution!")); 
     387                throw new InvalidOperationException("The DefaultMethod class should never " + 
     388                    "be used and should instead be replaced before execution!"); 
    389389            } 
    390390        } 
     
    473473            //Check for a valid constructor. 
    474474            if (ctor == null) 
    475                 throw new ArgumentException(S._("Registered erasure methods must contain " + 
     475                throw new ArgumentException("Registered erasure methods must contain " + 
    476476                    "a parameterless constructor that is called whenever clients request " + 
    477477                    "for an instance of the method. If a constructor requires parameters, " + 
    478                     "specify it in the parameters parameter.")); 
     478                    "specify it in the parameters parameter."); 
    479479 
    480480            //Insert the entry 
     
    498498        { 
    499499            if (!ManagerLibrary.Instance.ErasureMethodManager.methods.ContainsKey(value)) 
    500                 throw new ArgumentException(S._("The GUID of the erasure method to remove " + 
    501                     "refers to an invalid erasure method.")); 
     500                throw new ArgumentException("The GUID of the erasure method to remove " + 
     501                    "refers to an invalid erasure method."); 
    502502 
    503503            ManagerLibrary.Instance.ErasureMethodManager.methods.Remove(value); 
  • branches/eraser6/CodeReview/Eraser.Manager/PRNG.cs

    r1681 r1767  
    104104            if (minValue > maxValue) 
    105105                throw new ArgumentOutOfRangeException("minValue", minValue, 
    106                     S._("minValue is greater than maxValue")); 
     106                    "minValue is greater than maxValue"); 
    107107            else if (minValue == maxValue) 
    108108                return minValue; 
  • branches/eraser6/CodeReview/Eraser.Manager/Schedule.cs

    r1681 r1767  
    273273                if (ScheduleType != RecurringScheduleUnit.Daily && ScheduleType != RecurringScheduleUnit.Weekly && 
    274274                    ScheduleType != RecurringScheduleUnit.Monthly) 
    275                     throw new InvalidOperationException(S._("The ScheduleUnit of the schedule " + 
    276                         "does not require a frequency value, this field would contain garbage.")); 
     275                    throw new InvalidOperationException("The ScheduleUnit of the schedule " + 
     276                        "does not require a frequency value, this field would contain garbage."); 
    277277 
    278278                return frequency; 
     
    314314            { 
    315315                if (ScheduleType != RecurringScheduleUnit.Weekly) 
    316                     throw new InvalidOperationException(S._("The ScheduleUnit of the schedule " + 
    317                         "does not require the WeeklySchedule value, this field would contain garbage")); 
     316                    throw new InvalidOperationException("The ScheduleUnit of the schedule " + 
     317                        "does not require the WeeklySchedule value, this field would contain garbage"); 
    318318 
    319319                return weeklySchedule; 
     
    340340            { 
    341341                if (ScheduleType != RecurringScheduleUnit.Monthly) 
    342                     throw new InvalidOperationException(S._("The ScheduleUnit of the schedule does " + 
    343                         "not require the MonthlySchedule value, this field would contain garbage")); 
     342                    throw new InvalidOperationException("The ScheduleUnit of the schedule does " + 
     343                        "not require the MonthlySchedule value, this field would contain garbage"); 
    344344 
    345345                return monthlySchedule; 
     
    470470        { 
    471471            if (ScheduleType != RecurringScheduleUnit.Weekly) 
    472                 throw new ArgumentException(S._("The ScheduleUnit of the schedule does " + 
    473                     "not use the WeeklySchedule value, this field would contain garbage")); 
     472                throw new ArgumentException("The ScheduleUnit of the schedule does " + 
     473                    "not use the WeeklySchedule value, this field would contain garbage"); 
    474474            return ((int)weeklySchedule & (1 << (int)date.DayOfWeek)) != 0; 
    475475        } 
  • branches/eraser6/CodeReview/Eraser.Manager/Task.cs

    r1765 r1767  
    183183            { 
    184184                if (value.Owner != null) 
    185                     throw new ArgumentException(S._("The schedule provided can only " + 
    186                         "belong to one task at a time")); 
     185                    throw new ArgumentException("The schedule provided can only " + 
     186                        "belong to one task at a time"); 
    187187 
    188188                if (schedule is RecurringSchedule) 
Note: See TracChangeset for help on using the changeset viewer.