Added custom error creation method.