Hello @tejashriw155148,
Error page comes in action when there is some issue with the page and the error page content is displayed.
If you want to show error then you can store that error in content variables like
ctx.vars.line1="ERROR_2_CONTENT HERE";
ctx.vars.line2="ERROR_2_CONTENT_HERE";
and then you can print the error like this.
<%if (condition==true){
your logc here
}else{
%>
<%= ctx.vars.line1 %>
<%
}
%>
Let me know if that works.