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

Adding an Error object #148

Merged
merged 4 commits into from
May 16, 2021
Merged

Adding an Error object #148

merged 4 commits into from
May 16, 2021

Conversation

Nyholm
Copy link
Contributor

@Nyholm Nyholm commented Apr 25, 2021

The end goal of this PR is to be able to run the parser and output a well formatted error message. I would really like to be able to create good "github actions code comments" (or commands). That is why I need to be able to get the errors in a more structured way.

This PR does not break BC.

@Nyholm
Copy link
Contributor Author

Nyholm commented Apr 25, 2021

Oh.. my normal style of coding is to write a bunch of changes and then see if the CI is green. I guess Github's new "security feature" requires a maintainer's approval to run the CI on this PR.

Comment on lines 27 to 41
if (! $this->configuration->isSilentOnError()) {
echo '/!\\ ' . $error->__toString() . "\n";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to make an abstraction of the error handling in this library (which I agree with), I would say that we also move this code into an StdErrorReporter or the like (so that we can also e.g. add an GitHubErrorReporter).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed some changes without the abstraction. When we are adding a third format, then I think it starts to make sense with an abstraction. Right now it is just a simple if statement.

lib/Error.php Outdated Show resolved Hide resolved
lib/Error.php Outdated Show resolved Hide resolved
lib/ErrorManager.php Outdated Show resolved Hide resolved
lib/Error.php Outdated Show resolved Hide resolved
@@ -20,9 +20,48 @@ public function __construct(Configuration $configuration)
$this->configuration = $configuration;
}

public function addError(Error $error): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more handy to have a method that takes scalar arguments and builds an Error VO internally, instead of having addError(new Error(…)) every time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, I wonder if I should use the existing error/warning method instead. The only downside is the argument order.. But I can live with ->error($message, $throwable, $file, $line)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you could target 0.5.x and break BC :)

Copy link
Contributor Author

@Nyholm Nyholm Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which way will make it quicker for me to use this feature in my project?
=)

Copy link
Member

@greg0ire greg0ire Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we just released 0.4.0, so it wouldn't make a lot of sense to release 0.5.0 with just that change. That being said, since ErrorManager is not final, adding arguments such as $file and $line would be a BC break for extending classes, so I'm not sure there is a choice either way.

Copy link
Member

@greg0ire greg0ire Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just merged #144 that will make 0.5.0 less empty, and also make it less likely for such changes to become BC breaks.

@Nyholm
Copy link
Contributor Author

Nyholm commented Apr 26, 2021

Hm.. I need approval again..

@greg0ire
Copy link
Member

Consider making a PR that upgrades to doctrine/coding-standard 9 or any other small thing, that way I can approve and merge it and you will be autonomous on this one ;)

@Nyholm
Copy link
Contributor Author

Nyholm commented Apr 26, 2021

I am a doctrine org contributor already...

Hm.. anyways: #149

lib/Environment.php Outdated Show resolved Hide resolved
@Nyholm
Copy link
Contributor Author

Nyholm commented May 13, 2021

Could I ask you to do a 0.4.x -> 0.5.x merge?

@Nyholm Nyholm force-pushed the error branch 2 times, most recently from 2373b84 to 7a5b6c6 Compare May 13, 2021 13:40
@Nyholm Nyholm changed the base branch from 0.4.x to 0.5.x May 13, 2021 14:03
@Nyholm
Copy link
Contributor Author

Nyholm commented May 13, 2021

I've updated the PR to target 0.5.x. CI will be green after 0.4.x -> 0.5.x merge.

@greg0ire
Copy link
Member

I'm AFK until tonight, will try to!

@greg0ire greg0ire closed this May 13, 2021
@greg0ire greg0ire reopened this May 13, 2021
@greg0ire greg0ire requested a review from wouterj May 13, 2021 20:41
@Nyholm
Copy link
Contributor Author

Nyholm commented May 14, 2021

Thank you for the help.

Im done with this PR now.

@greg0ire greg0ire merged commit c4ac6f1 into doctrine:0.5.x May 16, 2021
@greg0ire
Copy link
Member

Thanks @Nyholm !

@Nyholm
Copy link
Contributor Author

Nyholm commented May 16, 2021

Wohoo. Thank you for the reviews and merge!

@Nyholm Nyholm deleted the error branch May 16, 2021 11:48
@greg0ire greg0ire added this to the 0.5.0 milestone May 16, 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

Successfully merging this pull request may close these issues.

3 participants