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");
/*Do Operations Search Operations on DE.

set @confirmation = Success_URL

]%% <script runat="server" language="javascript">
 } catch(e) { 
 set @errorUrl= /*Some URL*/

 <script runat="server" language="javascript">
  • 2
    Why are you loading core 1.1.3? As far as I know, 1.1.1 is the current release. May 12, 2017 at 11:20
  • Have you spat out anything on the page before the redirect? You can't start writing to the buffer and then redirect. So any HTML/Writes/outputs before the code above might be your issue.
    – Macca
    May 15, 2017 at 14:14
  • Refer to this answer, this might help you.
    – Abhishek
    May 19, 2017 at 5:16
  • @AdamSpriggs - Actually, 1.1.5 is the latest library. May 25, 2017 at 13:01
  • I couldn't find any documentation that mentioned anything past 1.1.1 May 25, 2017 at 13:08

2 Answers 2


This is not a problem related to your code but a known SFMC issue. Unfortunately, it won't be fixed.

You need to either do a redirect outside of a try block or leverage a workaround shared by @Gortonington on StackExchange.


According to the SSJS documentation, there is a Redirect function available within the core SSJS library.

Here is the example below:

<script runat="server" language="javascript">
Platform.Load("core", "1.1.1");

try {
 catch(e) {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .