I found solution it's function throwIf
throwIf
example from docs:
SELECT throwIf(number = 3, 'Too many') FROM numbers(10);
link on documentation: https://clickhouse.com/docs/sql-reference/functions/other-functions#throwif