Changeset 2655


Ignore:
Timestamp:
5/24/2012 3:11:07 AM (2 years ago)
Author:
lowjoel
Message:

When we are run as a command application, the convention is to use ArgumentException? to indicate command line parameter errors. Catch them and show them to the user since he would be the only one to rectify it!

Location:
trunk/eraser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util/Win32ErrorCodes.cs

    r2647 r2655  
    6868                case SharingViolation:  return new SharingViolationException(); 
    6969                case BadCommand:        return new NotSupportedException(); 
     70                case BadArguments:      return new ArgumentException(); 
    7071            } 
    7172 
     
    99100        public const int BadCommand = 22; 
    100101        public const int NotSupported = 50; 
     102        public const int BadArguments = 160; 
    101103    } 
    102104} 
  • trunk/eraser/Eraser/Program.cs

    r2617 r2655  
    325325                        new ConsoleActionData(CommandHelp, new ConsoleArguments())); 
    326326                    program.Handlers.Add("erase", 
    327                         new ConsoleActionData(CommandErase, new EraseArguments()));  
     327                        new ConsoleActionData(CommandErase, new EraseArguments())); 
    328328                    program.Handlers.Add("addtask", 
    329329                        new ConsoleActionData(CommandAddTask, new TaskArguments())); 
     
    343343                    Console.WriteLine(e.Message); 
    344344                    return e.ErrorCode; 
     345                } 
     346                catch (ArgumentException e) 
     347                { 
     348                    Console.WriteLine(e.Message); 
     349                    return Win32ErrorCode.BadArguments; 
    345350                } 
    346351                catch (Exception e) 
Note: See TracChangeset for help on using the changeset viewer.