def fail(message: nil, exception_class: RuntimeError)
      message.nil? ? message = "Fail in #{name}" : message = "Fail in #{name}: #{message}"
      e = exception_class.new(message)

      # If the caller is Origen.app.fail!, remove this caller from the backtrace, leaving where Origen.app.fail! was called.
      # As an aside, if there's an exception raised in Origen.app.fail!, then that would actually raise a Kernel.fail, so there's no concern with masking
      # out a problem with Origen.app.fail! by doing this.
      if caller[0] =~ (/lib\/origen\/application.rb:\d+:in `fail!'/)
        e.set_backtrace(caller[1..-1])
      else
        e.set_backtrace(caller)
      end
      Kernel.fail(e)
    end
def fail(message: nil, exception_class: RuntimeError)
      message.nil? ? message = "Fail in #{name}" : message = "Fail in #{name}: #{message}"
      e = exception_class.new(message)

      # If the caller is Origen.app.fail!, remove this caller from the backtrace, leaving where Origen.app.fail! was called.
      # As an aside, if there's an exception raised in Origen.app.fail!, then that would actually raise a Kernel.fail, so there's no concern with masking
      # out a problem with Origen.app.fail! by doing this.
      if caller[0] =~ (/lib\/origen\/application.rb:\d+:in `fail!'/)
        e.set_backtrace(caller[1..-1])
      else
        e.set_backtrace(caller)
      end
      Kernel.fail(e)
    end
Prepends the application name to the fail message and throws a RuntimeError exception.
 Very similar to the plain <code>fail</code> method with the addition of prepending the application name.
 Prepended message: 'Fail in app.name: '
 If no message if provided, message is set to 'Fail in app.name'
 @param message [String] Message to print with the exception. If the message option is nil, a default message will be used instead.
 @param exception_class [Class] Custom Exception class to throw. May require the full namespace, e.g. <code>Origen::OrigenError</code> instead of just <code>OrigenError</code>.
 @raise [RuntimeError, exception_class] Option exception_class is raised, defaulting to <code>RuntimeError</code>.