Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F12552732
fallback_controller.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
fallback_controller.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.MastodonAPI.FallbackController
do
use
Pleroma.Web
,
:controller
def
call
(
conn
,
{
:error
,
%
Ecto.Changeset
{}
=
changeset
})
do
error_message
=
changeset
|>
Ecto.Changeset
.
traverse_errors
(
fn
{
message
,
_opt
}
->
message
end
)
|>
Enum
.
map_join
(
", "
,
fn
{
_k
,
v
}
->
v
end
)
conn
|>
put_status
(
:unprocessable_entity
)
|>
json
(%{
error
:
error_message
})
end
def
call
(
conn
,
{
:error
,
:not_found
})
do
render_error
(
conn
,
:not_found
,
"Record not found"
)
end
def
call
(
conn
,
{
:error
,
:forbidden
})
do
render_error
(
conn
,
:forbidden
,
"Access denied"
)
end
def
call
(
conn
,
{
:error
,
error_message
})
do
conn
|>
put_status
(
:bad_request
)
|>
json
(%{
error
:
error_message
})
end
def
call
(
conn
,
{
:error
,
status
,
message
})
do
conn
|>
put_status
(
status
)
|>
json
(%{
error
:
message
})
end
def
call
(
conn
,
_
)
do
conn
|>
put_status
(
:internal_server_error
)
|>
json
(
dgettext
(
"errors"
,
"Something went wrong"
))
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Nov 15, 1:04 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
632094
Default Alt Text
fallback_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment