You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✏️ Describe the bug
In the case of trying to use laravel-data objects to make handling external API responses easier, there'll probably be a lot of nested DTO objects that need to be instantiated when using OuterClass::from($response->json()). If there's a typo in one of the nested classes, or I fail to add the proper #[MapInputName(...)] attribute, there'll be an exception somewhere inside the pipeline along the lines of InnerClass::__construct(): expects 2 arguments, 1 given correct_arg, missing arg_with_tpyo.
The issue is, that this error message never makes it to me, the developer. The error message I get is something like TypeError: App\DTOs\OuterObject::__construct(): Argument #1 ($innerObjects) must be of type Illuminate\Support\Collection, array given instead, which masquerades the root issue completely. After some small investigation, I found that this silent failure error is happening on this line. The CannotCreateData exception has the correct error message, but instead of rethrowing the exception, or logging the error, it just ignores it completely.
✅ Expected behavior
I expect to see the message Could not create InnerClass: the constructor requires 2 parameters, 1 given. Parameters given: arg2. Parameters missing: arg1.
🖥️ Versions
Laravel: 11.9
Laravel Data: 4.7
PHP: 8.3
The text was updated successfully, but these errors were encountered:
✏️ Describe the bug
In the case of trying to use laravel-data objects to make handling external API responses easier, there'll probably be a lot of nested DTO objects that need to be instantiated when using
OuterClass::from($response->json())
. If there's a typo in one of the nested classes, or I fail to add the proper#[MapInputName(...)]
attribute, there'll be an exception somewhere inside the pipeline along the lines ofInnerClass::__construct(): expects 2 arguments, 1 given correct_arg, missing arg_with_tpyo
.The issue is, that this error message never makes it to me, the developer. The error message I get is something like
TypeError: App\DTOs\OuterObject::__construct(): Argument #1 ($innerObjects) must be of type Illuminate\Support\Collection, array given
instead, which masquerades the root issue completely. After some small investigation, I found that this silent failure error is happening on this line. TheCannotCreateData
exception has the correct error message, but instead of rethrowing the exception, or logging the error, it just ignores it completely.↪️ To Reproduce
See test in this example project.
✅ Expected behavior
I expect to see the message
Could not create
InnerClass: the constructor requires 2 parameters, 1 given. Parameters given: arg2. Parameters missing: arg1.
🖥️ Versions
Laravel: 11.9
Laravel Data: 4.7
PHP: 8.3
The text was updated successfully, but these errors were encountered: