Best way for handle missing args in REST interface in vibed

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 29 06:11:28 PDT 2017


I wrote next code:

         void foo(string _error = null)
         {
             writeln("Error");
         }
     override:
         @errorDisplay!foo
         Json doTrackSpeedAnalyze(int trackid, string 
startDateTime, string endDateTime) // 
/api/mytrack?trackid=123&startDateTime=2000&endDateTime=2010
         {
             if(endDateTime.length == 0)
             {
                 throw new Exception("End Date must not be empty");
             }
             return Json.emptyObject;
         }

If I access to url:  /api/mytrack?trackid=123&startDateTime=2000 
(witout endDateTime) I am expecting execution foo() block, but it 
does not happens. Why?

And what do Exception here? Why should handle it?


More information about the Digitalmars-d-learn mailing list