tomkuijsten / restup

Webserver for universal windows platform (UWP) apps
MIT License
114 stars 48 forks source link

Restup.Webserver.Models.Schemas.GetResponse.ResponseStatus needs an error #99

Open ghost opened 7 years ago

ghost commented 7 years ago
    public enum ResponseStatus
    {
        OK = 200,
        NotFound = 404
        Error = 500
    }

(you could also fill out that graph with a whole host of others....

Love the code... So far works really well. I'll let you know if I come upon anything else.

tomkuijsten commented 7 years ago

We could ofcourse extend that list with all possible HTTP status, but these are the only viable ones as a response to a GET request.

If you want an error response, you can just throw an exception and it will generate a 400 error.

Hope that helps you.

Jark commented 7 years ago

I think it's easier to understand if you think of the IGetResponse, IPostResponse, IPutResponse, IDeleteResponse as the response to the intent of the request.

Imo we should expand the error codes slightly for the IPostResponse / IPutResponse (Unauthorized, for example) to represent more clearer error intentions, but for the GetResponse I think we've covered them.

@tomkuijsten as a side note it might be nice to add a BadRequestException that will convert into a 400 error and any other unhandled exceptions can then be converted to 500 (InternalServerError). This might capture what a user might expect better.

tomkuijsten commented 7 years ago

Might be a good idea to add something as a ErrorResponse (instead of an exception) which can always be returned with a error code > 400. Let's create an issue for this to design the thing.