8

By default an error is logged when I abort a pipeline in Sitecore XC9.

For example;

context.Abort("Abort pipeline", context);

Sometimes I want to abort a pipeline without logging an error, i.e. when it's valid to preempt the execution of the pipeline.

How to do this?

3
  • 1
    @Dan Sinclair why did you remove the sitecore-commerce tag?
    – Joost
    Nov 28 '18 at 13:46
  • Because this is not a commerce-specific question/solution. This appears to apply to any pipeline abort command; is that right? Nov 28 '18 at 14:26
  • 1
    No this is for XC only
    – Mark Cassidy
    Nov 28 '18 at 15:55
19

Add a magic "Ok|" string to the abort message, e.g:

context.Abort("Ok|Abort pipeline", context);

It turns out that the implementation of Abort checks for the magic "Ok|" string:

public override void Abort(string message, object context)
{
   base.Abort(message, context);
   if (message.Contains("Ok|"))
      return;
   this.Logger.LogError(string.Format("PipelineAbort:{0}", (object) message), Array.Empty());
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.