-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Dump and read the first error of service for XML and YAML format #34928
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -937,4 +937,26 @@ public function hasErrors(): bool | |
{ | ||
return (bool) $this->errors; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function getFirstError(): ?string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nicolas-grekas This new internal method avoid to potentially compute several error messages, to finally only use the first one in all of our usage. |
||
{ | ||
if (!$this->hasErrors()) { | ||
return null; | ||
} | ||
|
||
$error = $this->errors[0]; | ||
|
||
if ($error instanceof \Closure) { | ||
return (string) $error(); | ||
} | ||
|
||
if (!\is_string($error)) { | ||
return (string) $error; | ||
} | ||
|
||
return $error; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ | |
<xsd:attribute name="decoration-priority" type="xsd:integer" /> | ||
<xsd:attribute name="autowire" type="boolean" /> | ||
<xsd:attribute name="autoconfigure" type="boolean" /> | ||
<xsd:attribute name="error" type="xsd:string" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading the error is good for us, but that also mean it can be defined by users with this new attribute (preferred to keep things simple with an attribute btw). We open this new possibility. I'm not sure it's good 🤔 That makes it a feature too? That means it can't really go on 4.4 and that we can't fix the linked issue like this? I need some input on all of this, thanks. |
||
</xsd:complexType> | ||
|
||
<xsd:complexType name="instanceof"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,3 +177,4 @@ services: | |
public: true | ||
errored_definition: | ||
class: stdClass | ||
error: Service "errored_definition" is broken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting everything like this seems like the easier and faster option.