How can I make UPDATE to return an error if no rows are affected in Postgresql?
It would be possible to put the UPDATE into a CTE and then do something with the number of results:
WITH cte AS (
  UPDATE ...
  RETURNING ...
)
SELECT 1 / COUNT(*) FROM cte;

If the division by zero is too obscure for you, write a function that raises a proper error.
Personally, I would use a plain UPDATE, and then in my application, wrap all such SQL calls in a function that checks the number of rows. (PG returns that number from every UPDATE, but not every database driver supports this.)