Intercept error 400 in post_process?


Just wondering if I can intercept a 400 error in the post-process script.
I am trying to work out a auto user register routine where I first try and log them into a session, if that fails I register them as a new user and log the new user in.
Currently I don’t know how to intercept the 400 error in the server-side scripts and have to rely on the initial network call to error out and then make another network call from the client to register and login.
Just trying to avoid multiple network calls from the client side if possible


When an error occurs an exception is thrown and the post-process script is not run. You could write a custom script to have more control. Credentials can be included when calling the custom script. The script might look like this:

var result ="user/session", jsonCredentials);
// dump result to dsp log file
// check for code number of interest
if (result.error) {
    if (result.error[0].code === 400) {
        // register user
        // login user and return session data to caller of custom script
    } else {
        // some other error
} else {
   // return session data
  return result;

We have a blog post that gives an overview of how to use custom scripts:


Nice idea but I’m hitting the 401-unauthorised error.
mmm, tricky to get passed that one when I’m trying to call it to do an initial user login/registration :smile:


I haven’t tried this, just throwing out some ideas. You need to know the difference between new user and existing user with wrong password. Both return 401. Your script could query the users table to see if the email already exists. If so try to get a session using the supplied credentials. Otherwise create a new user, and get a session.