# How to debug

This article describes how to use the Authing console to debug Pipeline functions.

We have created the first Pipeline function, and at the same time review the function code as:

async function pipe(context, callback) {
  const email = context.data.userInfo.email;
  // Non-email registration method
  if (!email) {
    return callback(null, context);
  }
  if (!email.endsWith("example.com")) {
    return callback(new Error("Access denied."));
  }
  return callback(null, context);
}

The function of the Pipeline function is to only allow the registration of mailboxes whose domain name suffix is ​​example.com.

Click the debug button of the Pipeline function:

Click this button to open the debugging window: Authing will according to your user pool to produce corresponding test data.

**Note that the data.userInfo.email in the test data is xxxxxx@example.com. **

Click the "Debug" button: the debug result is output below, and we get the latest context object, indicating that this mailbox has passed the Pipeline function.

We then changed the email suffix to qq.com, and we got the corresponding error message in the output area.

# View log

You need to use the Authing Pipeline global built-in function log to view the running log, not console.log!

Use the function editor to modify the code and add a line at the beginning of the function: Note that it is log instead of console.log.

log(context);

Click "Debug" again to see the output log.

If there is no log output, please try again!

# Catch syntax errors

If your function has a syntax error, Authing Pipeline can also catch it. Here we modify the code and add a line of xxxxxxx at the beginning of the pipe function:

Click Debug again, you can see the corresponding error message: message: “xxxxxxx is not defined”.

We recommend using the debugger to debug the code first before sending this function online.