gorse-io / Gorse.NET

.NET SDK for gorse recommender system
Apache License 2.0
6 stars 2 forks source link

Potential bug: Unexpected Exception for Null Response in Gorse.NET #11

Open nebHailemariam opened 1 day ago

nebHailemariam commented 1 day ago

Hi @zhenghaoz,

I encountered an issue when using the GetRecommend(string userId) method, which calls "api/recommend/" + userId endpoint in the Gorse.NET library. When the Gorse server returns a null response, the library throws a GorseException with the message "unexpected empty response."

Here’s the relevant code:

throw new GorseException
{
    StatusCode = HttpStatusCode.InternalServerError,
    Message = "unexpected empty response"
}; 

Expected Behavior:

If the Gorse server returns a null response, I believe it would be more appropriate for the library to return null rather than throwing an exception. This change would allow end users to handle null responses more gracefully according to their specific requirements.

Should I open a pull request to fix this problem?

zhenghaoz commented 1 day ago

Thank you! Pull requests are welcome😁


From: Nebiyou Hailemariam @.> Sent: Thursday, October 24, 2024 8:23 To: gorse-io/Gorse.NET @.> Cc: zhenghaoz @.>; Mention @.> Subject: [gorse-io/Gorse.NET] Potential bug: Unexpected Exception for Null Response in Gorse.NET (Issue #11)

Hi @zhenghaozhttps://github.com/zhenghaoz,

I encountered an issue when using the GetRecommend(string userId), which calls "api/recommend/" + userId whimethod in the Gorse.NET library. When the Gorse server returns a null response, the library throws a GorseException with the message "unexpected empty response."

Here’s the relevant code:

throw new GorseException { StatusCode = HttpStatusCode.InternalServerError, Message = "unexpected empty response" };

Expected Behavior:

If the Gorse server returns a null response, I believe it would be more appropriate for the library to return null rather than throwing an exception. This change would allow end users to handle null responses more gracefully according to their specific requirements.

Should I open a pull request to fix this problem?

— Reply to this email directly, view it on GitHubhttps://github.com/gorse-io/Gorse.NET/issues/11, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACE4T2H5LHWMB53M6XLOSDDZ5A4ZVAVCNFSM6AAAAABQP5NGY6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYTAMBZG4YDQMY. You are receiving this because you were mentioned.Message ID: @.***>