improve error handling and logging for micropub_handler
This commit is contained in:
parent
d38a897b8f
commit
3c6e239659
1 changed files with 7 additions and 5 deletions
|
@ -7,20 +7,22 @@ defmodule ChiyaWeb.Indie.MicropubHandler do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_create(type, properties, access_token) do
|
def handle_create(type, properties, access_token) do
|
||||||
dbg(properties)
|
Logger.info("Handle create")
|
||||||
dbg(type)
|
Logger.info("Properties: #{properties}")
|
||||||
|
Logger.info("Type: #{type}")
|
||||||
|
|
||||||
with :ok <- verify_token(access_token),
|
with :ok <- verify_token(access_token),
|
||||||
{:ok, post_type} <- Props.get_post_type(properties),
|
{:ok, post_type} <- Props.get_post_type(properties),
|
||||||
{:ok, note_attrs} <- get_attrs(type, post_type, properties),
|
{:ok, note_attrs} <- get_attrs(type, post_type, properties),
|
||||||
{:ok, note} <- Chiya.Notes.create_note(note_attrs) do
|
{:ok, note} <- Chiya.Notes.create_note(note_attrs) do
|
||||||
{:ok, :created, Chiya.Notes.Note.note_url(note)} |> dbg()
|
Logger.info("Note created!")
|
||||||
|
{:ok, :created, Chiya.Notes.Note.note_url(note)}
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
Logger.error("Error occurred while creating note from micropub:")
|
Logger.error("Error occurred while creating note from micropub:")
|
||||||
dbg(error)
|
Logger.error(inspect(error))
|
||||||
|
|
||||||
{:error, :unhandled_error}
|
{:error, :invalid_request}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue