mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: properly handle failed bulk creates with no errors
This commit is contained in:
parent
43585d5617
commit
aa1f902c50
1 changed files with 16 additions and 0 deletions
|
@ -1883,6 +1883,22 @@ defmodule Ash.Api do
|
|||
api
|
||||
|> bulk_create(inputs, resource, action, opts)
|
||||
|> case do
|
||||
%Ash.BulkResult{status: :error, errors: []} ->
|
||||
if opts[:return_errors?] do
|
||||
raise Ash.Error.to_error_class(
|
||||
Ash.Error.Unknown.UnknownError.exception(
|
||||
error: "Something went wrong with bulk create, but no errors were produced."
|
||||
)
|
||||
)
|
||||
else
|
||||
raise Ash.Error.to_error_class(
|
||||
Ash.Error.Unknown.UnknownError.exception(
|
||||
error:
|
||||
"Something went wrong with bulk create, but no errors were produced due to `return_errors?` being set to `false`."
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
%Ash.BulkResult{status: :error, errors: errors} ->
|
||||
raise Ash.Error.to_error_class(errors)
|
||||
|
||||
|
|
Loading…
Reference in a new issue