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

Throw exception in ViewportAdapter constructor if the GraphicsDevice is null #838

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

safoster88
Copy link
Contributor

@safoster88 safoster88 commented Feb 17, 2024

If the viewport adapter is initialized in the constructor of game, GraphicsDevice will be null.

There is no check for this, so the null ref only occurs when trying to call GetViewMatrix().

This PR aims to improve the public API.

@Gandifil Gandifil self-requested a review April 7, 2024 20:21
@Gandifil Gandifil self-assigned this Apr 7, 2024
@Gandifil
Copy link
Collaborator

Gandifil commented Apr 7, 2024

Firstly, thank you for attention!

It's a good idea, but why do you use the custom exception? There is ArgumentNullException.
It can be simply:
if (graphicsDevice is null) throw new ArgumentNullException(nameof(graphicsDevice));

People often use this way, so more easy to understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants