hassanhabib / RESTFulSense

A RESTFul operations client that serializes responses and throws meaningful exceptions for >= 400 status codes.
https://www.restfulsense.com
237 stars 51 forks source link

FEATURE: Create HTTP Errors Easily in `WebAssembly` Project #150

Open ElbekDeveloper opened 9 months ago

ElbekDeveloper commented 9 months ago

Currently if you want to create exceptions for unit tests, when you are using WebAssembly library, you have to do the following:

public static TheoryData CriticalDependencyExceptions()
{
    string someMessage = GetRandomMessage();
    var someResponseMessage = new HttpResponseMessage();

    return new TheoryData<Xeption>()
    {
        new HttpResponseUrlNotFoundException(
            someResponseMessage,
            someMessage),

        new HttpResponseUnauthorizedException(
            someResponseMessage,
            someMessage),

        new HttpResponseForbiddenException(
            someResponseMessage,
            someMessage)
    };
}

At the same time Core project made it easier to create the above exceptions without response message and message.