@@ -122,6 +122,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Resource do
|
||||
{:ok, _, %Resource{} = resource} ->
|
||||
{:ok, resource}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:error, changeset}
|
||||
|
||||
{:error, _err} ->
|
||||
{:error, dgettext("errors", "Error while creating resource")}
|
||||
end
|
||||
|
||||
@@ -63,6 +63,10 @@ defmodule Mobilizon.Resources.Resource do
|
||||
|> maybe_add_published_at()
|
||||
|> validate_resource_or_folder()
|
||||
|> validate_required(@required_attrs)
|
||||
|> validate_length(:title, max: 200)
|
||||
|> validate_length(:summary, max: 400)
|
||||
|> validate_length(:resource_url, max: 400)
|
||||
|> validate_length(:path, max: 500)
|
||||
|> unique_constraint(:url, name: :resource_url_index)
|
||||
end
|
||||
|
||||
|
||||
@@ -119,7 +119,11 @@ defmodule Mobilizon.Resources do
|
||||
{:ok, resource}
|
||||
|
||||
{:error, operation, reason, _changes} ->
|
||||
{:error, "Error while inserting resource when #{operation} because of #{inspect(reason)}"}
|
||||
Logger.error(
|
||||
"Error while inserting resource when #{operation} because of #{inspect(reason)}"
|
||||
)
|
||||
|
||||
{:error, reason}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user