aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-11-12 12:09:41 -0500
committerDrew DeVault <sir@cmpwn.com>2020-11-12 12:09:41 -0500
commitaad5f44f6cb605589fa017bc521e47a4a517b57d (patch)
tree4a13ff32477292a4c5a175ad0459fe4622fb84f8 /plugins
parent231626a31a94c65dcce13765815f425b096ae2bb (diff)
downloadalps-aad5f44f6cb605589fa017bc521e47a4a517b57d.tar.gz
alps-aad5f44f6cb605589fa017bc521e47a4a517b57d.zip
Display server errors on attachment upload
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/routes.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index fa8f35b..df32876 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -737,18 +737,25 @@ func handleComposeNew(ctx *alps.Context) error {
func handleComposeAttachment(ctx *alps.Context) error {
reader, err := ctx.Request().MultipartReader()
if err != nil {
- return fmt.Errorf("failed to get multipart form: %v", err)
+ return ctx.JSON(http.StatusBadRequest, map[string]string{
+ "error": "Invalid request",
+ })
}
form, err := reader.ReadForm(32 << 20) // 32 MB
if err != nil {
- return fmt.Errorf("failed to decode multipart form: %v", err)
+ return ctx.JSON(http.StatusBadRequest, map[string]string{
+ "error": "Invalid request",
+ })
}
var uuids []string
for _, fh := range form.File["attachments"] {
uuid, err := ctx.Session.PutAttachment(fh, form)
if err != nil {
- return err
+ ctx.Logger().Printf("PutAttachment: %v\n", err)
+ return ctx.JSON(http.StatusBadRequest, map[string]string{
+ "error": "failed to store attachment",
+ })
}
uuids = append(uuids, uuid)
}