code: public static Attachment writeAttachmentSafely(byte[] attachment, String title, String type) {
          try {
              return type == null || type.isEmpty()
                      ? writeAttachment(attachment, title)
                      : writeAttachment(attachment, title, type);
  
          } catch (Exception e) {
              LOGGER.trace("Error while saving attachment " + title + ":" + type, e);
              return writeAttachmentWithErrorMessage(e, title);
          }
      }
docs: Write attachment uses {@link #writeAttachment(byte[], String, String)} (if
  specified attachment type not empty) or {@link #writeAttachment(byte[], String)}
  otherwise. If something went wrong uses
  {@link #writeAttachmentWithErrorMessage(Throwable, String)}
  
  @param attachment which will write
  @param title      attachment title
  @param type       attachment type (should be valid mime-type, empty string or null)
  @return Created {@link ru.yandex.qatools.allure.model.Attachment}