A unified stress-based approach to assess failure in solids and liquids