(ctx context.Context, err error, msg string, args ...interface{})
| 14 | ) |
| 15 | |
| 16 | func errorResponse(ctx context.Context, err error, msg string, args ...interface{}) util.JSONResponse { |
| 17 | if eerr, ok := err.(*jsonerror.MatrixError); ok { |
| 18 | var status int |
| 19 | switch eerr.ErrCode { |
| 20 | case "M_INVALID_ARGUMENT_VALUE": |
| 21 | status = http.StatusBadRequest |
| 22 | case "M_NOT_FOUND": |
| 23 | status = http.StatusNotFound |
| 24 | default: |
| 25 | status = http.StatusInternalServerError |
| 26 | } |
| 27 | return util.MatrixErrorResponse(status, eerr.ErrCode, eerr.Err) |
| 28 | } |
| 29 | util.GetLogger(ctx).WithError(err).Errorf(msg, args...) |
| 30 | return jsonerror.InternalServerError() |
| 31 | } |
| 32 | |
| 33 | func GetAllPushRules(ctx context.Context, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse { |
| 34 | ruleSets, err := queryPushRules(ctx, device.UserID, userAPI) |
no outgoing calls
no test coverage detected