How to stop 500 errors when UUID doesn't match

Please see my suggestion code in my Phoenix Controller :

   def create_cms_post(conn, %{"title" => _title, "status" => _status, "post_type" => _post_type, "download_ext_link" => _download_ext_link, "price" => _price, "pic_x1_link" => _pic_x1_link, "pic_x2_link" => _pic_x2_link, "pic_x3_link" => _pic_x3_link, "group_acl" => _group_acl, "description" => _description, "changelog" => _changelog, "changelog_category" => _changelog_category, "plugin" => _plugin, "plugin_category" => _plugin_category, "discourse" => _discourse, "discourse_link" => _discourse_link, "screen_shot" => _screen_shot, "screen_shot_category" => _screen_shot_category, "learn" => _learn, "learn_category" => _learn_category, "seo_tag" => _seo_tag, "seo_alias_link" => _seo_alias_link, "seo_words" => _seo_words, "seo_description" => _seo_description, "seo_language" => _seo_language, "seo_language_link" => _seo_language_link, "cms_post_category_id" => cms_post_category_id} = allreq) do
      create_post(conn, allreq, Ecto.UUID.cast(cms_post_category_id))
   end

   defp create_post(conn, _allreq, :error) do
      conn
      |> put_status(400)
      |> json(%{error_code: "400"}) 
   end

   defp create_post(conn, allreq, {:ok, _}) do
      create_cms_posts = case PostQuery.insert_post(allreq) do
            {:ok, _post} 		   -> 
               conn
               |> put_status(200)
               |> json(%{message: "The post has been created."})            
            {:error, _changeset}  ->
               conn
               |> put_status(403)
               |> json(%{error_code: "403"})
         end
      create_cms_posts     
   end

Does anyone have a suggestion whether my code is invalid or valid?