Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling design #286

Open
lszczygielek opened this issue Jan 20, 2021 · 0 comments
Open

Exception handling design #286

lszczygielek opened this issue Jan 20, 2021 · 0 comments
Assignees

Comments

@lszczygielek
Copy link

I like this library, I'm trying to consume it in my project.
I have issue with exception handling. Maybe I don't understand how exceptions are design in library.

Nuget version 4.2.0.

I have a code like:

try
{
        // projectId not exists - server will return 404.
	var project = redmineManager.GetObject<Project>(projectId, null);
}
catch (Exception e)
{
	// actions
}

I thought that e will be an exception derived from RedmineException but it's not.

This is what exception I have:

Exception: Name = "WebException" FullName = "System.Net.WebException" Message = "An exception occurred during a WebClient request."
    InnerException:    Name = "NotFoundException" FullName = "Redmine.Net.Api.Exceptions.NotFoundException" Message = "Not Found"
        InnerException of InnerException: Name = "WebException" FullName = "System.Net.WebException" Message = "The remote server returned an error: (404) Not Found."

Is it right flow? In my code now I have to catch WebException and check InnerException. It shouldn't be RedmineException the most outer?

@zapadi zapadi self-assigned this Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants