singularityError :: Integer -> Response
singularityError numRows =
  responseLBS HT.status406
    [toHeader CTSingularJSON]
    $ toS . formatGeneralError
      "JSON object requested, multiple (or no) rows returned"
      $ unwords
        [ "Results contain", show numRows, "rows,"
        , toS (toMime CTSingularJSON), "requires 1 row"
        ]
  where
    formatGeneralError :: Text -> Text -> Text
    formatGeneralError message details = toS . JSON.encode $
      JSON.object ["message" .= message, "details" .= details]
singularityError :: Integer -> Response
singularityError numRows =
  responseLBS HT.status406
    [toHeader CTSingularJSON]
    $ toS . formatGeneralError
      "JSON object requested, multiple (or no) rows returned"
      $ unwords
        [ "Results contain", show numRows, "rows,"
        , toS (toMime CTSingularJSON), "requires 1 row"
        ]
  where
    formatGeneralError :: Text -> Text -> Text
    formatGeneralError message details = toS . JSON.encode $
      JSON.object ["message" .= message, "details" .= details]
singularityError numRows =
  responseLBS HT.status406
    [toHeader CTSingularJSON]
    $ toS . formatGeneralError
      "JSON object requested, multiple (or no) rows returned"
      $ unwords
        [ "Results contain", show numRows, "rows,"
        , toS (toMime CTSingularJSON), "requires 1 row"
        ]
  where
    formatGeneralError :: Text -> Text -> Text
    formatGeneralError message details = toS . JSON.encode $
      JSON.object ["message" .= message, "details" .= details]