I am trying to error Handle my Cloud page in SFMC.
If anything goes wrong in the Ampscript Block, user should be redirected to an error page. There is a success scenario where I redirect the user to Success page within Ampscript.
I have tried using a mix of SSJS and AmpScript. Here is a Sample code. Is there a way of doing a redirect through SSJS directly instead of using a mix of SSJS and AMPScript
Issue with this code is if I comment out the Success Redirection, it works. If I put both redirects, it goes to the catch block every time
<script runat="server" type="text/javascript">
Platform.Load("core", "1.1.3");
try{
</script>
%%[
/*Do Operations Search Operations on DE.
set @confirmation = Success_URL
Redirect(@Confirmation)
]%% <script runat="server" language="javascript">
} catch(e) {
</script>
%%[
set @errorUrl= /*Some URL*/
Redirect(@errorUrl)
]%%
<script runat="server" language="javascript">
}
</script>