Best way for handle missing args in REST interface in vibed

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 29 05:45:43 PDT 2017


On Monday, 29 May 2017 at 12:23:59 UTC, Suliman wrote:
> I am doing REST interface with vibed. And thinking about 
> handling errors, if users forgot to pass all expected args in 
> function.
>
> For example:
> foo(int x, int y) // get request
> {
>
> }
>
> /api/foo?x=111
>
> And if user is forgot to pass `y` we will get error in the 
> browser. What is the right way to handle curch cases?
>
> Wrap is with try-catch looks wrong.

That depends on wether or not there is a sensible default for y, 
if so
     foo(int x, int y=0)
ought to work.


More information about the Digitalmars-d-learn mailing list