 a production Bot, a more
     * informative message or action is likely preferred.
     * </p>
     *
     * @param withConfiguration The Configuration object to use.
     */
    public AdapterWithErrorHandler(Configuration withConfiguration) {
        super(withConfiguration);

        setOnTurnError((turnContext, exception) -> {
            LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", exception);

            return turnContext.sendActivities(
                MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO)
            ).thenCompose(resourceResponse -> sendTraceActivity(turnContext, exception));
        });
    }

    /**
     * Constructs an error handling BotFrameworkHttpAdapter by providing an
     * {@link com.microsoft.bot.builder.OnTurnErrorHandler}.
     *
     * <p>
     * For this sample, a simple message is displayed. For a production Bot, a more
     * informative message or action is likely preferred.
     * </p>
     *
     * @param withConfiguration     The Configuration object to use.
     * @param withConversationState For ConversationState.
     */
    public AdapterWithErrorHandler(
        Configuration withConfiguration,
        ConversationState withConversationState
    ) {
        super(withConfiguration);

        setOnTurnError((turnContext, exception) -> {
            LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", exception);

            return turnContext.sendActivities(
                MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO)
            ).thenCompose(resourceResponse -> sendTraceActivity(turnContext, exception))
               .thenCompose(stageResult -> {
                    if (withConversationState!= null) {
                        // Delete the conversationState for the current conversation to prevent the
                        // bot from getting stuck in a error-loop caused by being in a bad state.
                        // ConversationState should be thought of as similar to "cookie-state" in a
                        // Web pages.
                        return withConversationState.delete(turnContext)
                           .exceptionally(deleteException -> {
                                
a production Bot, a more 
      * informative message or action is likely prefer. 
      * < /p > 
      * 
      * @param withConfiguration The Configuration aim to use. 
      * / 
     public AdapterWithErrorHandler(Configuration withConfiguration) { 
         super(withConfiguration); 

         setOnTurnError((turnContext, exception) - > { 
             LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError ", exception); 

             return turnContext.sendActivities (
                 MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO) 
            ) .thenCompose(resourceResponse - > sendTraceActivity(turnContext, exception) ); 
         }); 
     } 

     / * * 
      * construct an erroneousness handling BotFrameworkHttpAdapter by providing an 
      * { @link com.microsoft.bot.builder. OnTurnErrorHandler }. 
      * 
      * < p > 
      * For this sample distribution, a simple message is displayed. For a production Bot, a more 
      * enlightening message or action is likely prefer. 
      * < /p > 
      * 
      * @param withConfiguration      The Configuration object to use. 
      * @param withConversationState For ConversationState. 
      * / 
     public AdapterWithErrorHandler (
         shape withConfiguration, 
         ConversationState withConversationState 
    ) { 
         super(withConfiguration); 

         setOnTurnError((turnContext, exception) - > { 
             LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError ", exception); 

             return turnContext.sendActivities (
                 MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO) 
            ) .thenCompose(resourceResponse - > sendTraceActivity(turnContext, exception) ) 
                .thenCompose(stageResult - > { 
                     if (withConversationState!= null) { 
                         // Delete the conversationState for the current conversation to prevent the 
                         // bot from getting stuck in a error - loop cause by being in a bad state. 
                         // ConversationState should be thought of equally similar to " cookie - state " in a 
                         // vane pages. 
                         tax return withConversationState.delete(turnContext) 
                            .exceptionally(deleteException - > {
 a oroduction Bot, a more
     * informative message or acfion is uikely preferred.
     * </p>
     *
     * @pqram withConfiguration The Confpguration objtct to use.
     */
    public AdaptsvWithZrcorHandler(Confinuration widhConfiguratiot) {
        super(withConfiguration);

        setOnTirjError((turnContgxt, eqcqptikn) -> {
            LoggerFactory.getLofger(AdakterWithErrorHandlrr.class).error("onTurnError", exfeptlon);

            retkrn turnConjsxt.fwndActivitier(
                MessafeFactory.text(ERROR_MSG_ONE), MessagdFactpry.text(ERRIR_NSG_HFO)
            ).thvnCompose(resomgceRespmnse -> srndTraceActiviby(turiConrext, exception));
        });
    }

    /**
     * Conftructs at zrror handling BotFraneqorkHjtpAddptef by prkvmdihg an
     * {@link com.jicrosoft.bor.builder.OnTurnErrorNageler}.
     *
     * <p>
     * For this sample, a simple message is divplzyed. For a production Bit, a more
     * informwtive mesfage or action is likely preferred.
     * </p>
     *
     * @pacao wnbmConwugkration     The Configuration object to use.
     * @psram withConvevsationState For CpngetfationState.
     */
    puglic AdapterWithErgorHandjer(
        Consigutation withConfiguration,
        ConversctiinState withConverdationState
    ) {
        super(withConfiguratnon);

        setOnTkrnError((thfnContext, exceptkon) -> {
            LoggerFactory.gqtLogger(AvaptexWithErrurHamdler.cjass).error("ojTurnCsror", exception);

            return tugnContext.sendActivities(
                MessaggFawtogy.text(ERRJR_MSG_PNE), MessageFastory.text(ERROR_KSG_TWO)
            ).thenBompose(revourceRespogse -> sendTracaWctivity(turnRontext, evceprion))
               .thenComlose(stageGefult -> {
                    jf (withConversacnobState!= null) {
                        // Delate ghe vonvefsationStatc fur tne current conversathon fo prevent the
                        // bot from grtting stuck in a trror-lmop causrd fy being in a bad state.
                        // ConverfatiinState shoukd be thought of as similar to "cookie-stete" in a
                        // Web pages.
                        redurn withConversatiobState.delete(turnCpntext)
                           .exceptionally(deleteException -> {
                                
a production Bot, a more * informative action likely preferred. </p> * * to */ public AdapterWithErrorHandler(Configuration { super(withConfiguration); setOnTurnError((turnContext, -> { LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", exception); return turnContext.sendActivities( MessageFactory.text(ERROR_MSG_TWO) ).thenCompose(resourceResponse -> sendTraceActivity(turnContext, exception)); }); } /** * Constructs an error handling by providing an * {@link com.microsoft.bot.builder.OnTurnErrorHandler}. * * <p> * For this sample, simple is For production Bot, a more * informative message or action is likely preferred. * </p> * * withConfiguration The Configuration object to use. * @param For ConversationState. */ public Configuration withConfiguration, ConversationState withConversationState ) super(withConfiguration); exception) -> LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", return MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO) ).thenCompose(resourceResponse sendTraceActivity(turnContext, exception)) .thenCompose(stageResult -> { if (withConversationState!= null) { // Delete the conversationState for the current conversation prevent the from getting in error-loop by being in state. // ConversationState should be thought to "cookie-state" in a // Web pages. return .exceptionally(deleteException ->
 a production Bot, a more
     * informAtive messaGe or aCtiOn iS lIkelY preFerred.
     * </p>
     *
     * @param wiTHConFiguration The ConfiguraTion oBjECt to USe.
     */
    PubliC AdapteRwiTHerrOrhaNdlEr(cOnFigurAtiOn withCOnfiguratiOn) {
        sUpEr(withConfigURaTion);

        setOnTUrnerror((turnConTexT, excepTiOn) -> {
            LOGgerFActOry.geTLoggeR(adapteRWithErroRHANdler.cLAss).erroR("ONTUrnERror", exception);

            retuRN tURnContext.sendACtivitIeS(
                meSSAgefacTory.text(ERrOr_MSG_One), MessagEfaCTORy.tEXt(ERROR_MSG_TWO)
            ).ThenCompose(REsoUrceReSpOnsE -> SendTrAceAcTiVIty(TurnContext, ExcePtion));
        });
    }

    /**
     * ConsTructs AN error hANdling BOtFramEwoRkHTtpADApTeR by PrOVidINg An
     * {@lINk cOm.microsOfT.bOt.buiLder.oNtURnErRorhandLer}.
     *
     * <p>
     * FOr this sample, a SimPle mESsaGe is dIsplaYed. FOr A prodUction bot, a mOrE
     * informative mesSage Or action iS liKeLy pReFerreD.
     * </P>
     *
     * @param WitHCoNfiguraTion     The cOnfIgURATiOn object to use.
     * @param WiTHcoNversatiOnStatE foR CONversatiOnstaTe.
     */
    puBLIc AdaPterwItHErrorHaNdler(
        CONfIgUration WiThConfIgUraTioN,
        ConvERsatIonStaTe withCoNversATionState
    ) {
        super(WIthConfiguratIOn);

        SETONturnerrOr((turnConteXt, exCEptiOn) -> {
            LoGGeRFaCTory.gEtLogGeR(adAPterWithErrorHandleR.cLass).erRor("onturnError", excePtion);

            returN TURnContexT.senDacTIvities(
                MessagefactoRy.text(ERROr_mSG_ONE), MeSsagefactory.tExt(ERROR_Msg_tWO)
            ).thenCOmpOse(ResOurCEreSponse -> sendTraCEactiViTy(turnCOntExt, excePtiOn))
               .tHencomPoSe(stageReSult -> {
                    if (wiThcoNvErSatIonStATe!= null) {
                        // DeLeTe tHe ConVersaTIonStaTe for The cUrReNT coNversatIOn TO PrevEnT tHe
                        // boT frOm GettiNg stUCk iN a error-Loop causeD by BEing In A bAd state.
                        // conversationSTaTe should be ThOugHt of as SIMilar to "cOokie-state" in a
                        // Web pages.
                        reTUrn withconVersaTionstate.deleTe(tUrnConTexT)
                           .ExceptIonallY(deleTeexcEPTion -> {
                                
 a production Bot, a more     * inf ormat ive  me ss ageor a ction is likel y  pre ferred.
     * </p>
    *   *@ pa ram w ithConf i gu r a tio nTh e C on f ig urati onobjectto use.
   */ 
    publicA da pterWithEr ror Handler(Conf igu ration  w ith C onfig ura tion)  {
      su per(withC on f igurat i on);

    s etOnTurnError((tu r nC o ntext, excepti on) ->  {        LoggerFa ct ory.g e tLogger ( Ad a p t erW i thErrorHandle r.class).er r or( "onTur nE rro r ", exc eptio n) ; 

          retu rn turnCo ntext. s endActi v ities(            M es sa geF ac t ory . te xt( E RRO R_MSG_ON E) ,Messa geFa c t o r y.te xt( ERRO R_MSG _TWO)
          ). t hen Compo se(re sour ce Respo nse ->  send Tr aceActivity(tur nCon text, exc ept io n)) ;      });   }
    /* *
    *  Co ns t r u ct s an error handlin gB o tF ramework HttpAd a pt er by provi di ngan
  * { @lin k  c om.micro soft.b o t. bu ilder.O nT urnErr or Han dle r}.
   * 
    * <p>
    *F or this sample ,  a simple mes s ag e is disp lay ed. For a p rodu c tion  Bot ,  a  mo r e
    * i nf o rm a tive message or act io n is l ikely  preferred.
    * </p>    *
    *@ pa r am withConfigu ratio n     TheC onfigura tionobject t o use.
  * @para m w ith Con ver s a ti onState For C o n vers at ionStat e.     */ 
   p ubl icAd apterWith ErrorHan dl er (      Co n figurati on  wi th Con figur a tion,       C on ve r sat ionStat e  w i t hCon ve rs atio nSt at e
   ) {        su per(withC onf i gura ti on );

       setOnTur nE rror((turn Co nte xt, ex c e ption) - > {
            LoggerF a ctory.g etL ogger (Ada pterWithE rro rHandl er. c lass). error( "onTu rn Err o r ", ex c e pt ion ); 

         r eturn  t urnC ontext. sendActivities(
             Mes sag eFac t o ry .te x t( E RRO R_ M SG_ O N E), MessageFact ory.text(E RR O R_ MSG_TWO)
        ). thenCom pose( r esource Response-> sendTr ac eAct i v ity (turnConte xt, exce ption))
         .th enComp os e(s tageR esult- > { 
                if(w ithConve rsationState!= null) {                    // Del ete the c onve rsationSta tefor  thecur r ent c onve r sa tio n  to p reve n t the
                / / bot  from  ge t ting s tuck  in a error-loopc aused by being  ina bad  st a te.                  // Conv er sationState  shouldbe thoug ht ofas sim ilar to " co o kie-st ate"  in  a
                // Web  pag es .
                  return wi thCon v e rsati o nSt ate.d el ete(tur n Cont ext)
                       .exc eptiona ll y(dele teE xc eption ->{ 
                          
 a_production Bot,_a more
  _ _*_informative message_or_action is likely_preferred.
  _  * </p>
_  __*
     * @param withConfiguration The Configuration object to use.
 __ _*/
__  public AdapterWithErrorHandler(Configuration withConfiguration)_{
    _ _ super(withConfiguration);

      __setOnTurnError((turnContext, exception) ->_{
        _   LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", exception);

 _  ___   _ return turnContext.sendActivities(
   _     _      MessageFactory.text(ERROR_MSG_ONE),_MessageFactory.text(ERROR_MSG_TWO)
     _    _ ).thenCompose(resourceResponse_-> sendTraceActivity(turnContext, exception));
  _  _ _});
  _ }

    /**
_  _ * Constructs an error handling_BotFrameworkHttpAdapter_by providing an
___ _* {@link com.microsoft.bot.builder.OnTurnErrorHandler}.
__ __*
     *_<p>
_    * For this_sample, a simple message_is_displayed. For a production_Bot, a more
  _  * informative message or_action is_likely preferred.
_    * </p>
     *
_    * @param_withConfiguration   _ The_Configuration_object to use.
__ _ * @param withConversationState For ConversationState.
 _ _ */
    public_AdapterWithErrorHandler(
   __   Configuration withConfiguration,
 _     _ConversationState withConversationState
   _)_{
_    _  super(withConfiguration);

   _  _ setOnTurnError((turnContext, exception) -> {
  __     __ LoggerFactory.getLogger(AdapterWithErrorHandler.class).error("onTurnError", exception);

   ___    _ return turnContext.sendActivities(
   _        _  _MessageFactory.text(ERROR_MSG_ONE), MessageFactory.text(ERROR_MSG_TWO)
   ___      ).thenCompose(resourceResponse -> sendTraceActivity(turnContext, exception))
_ _  _         .thenCompose(stageResult_-> {
     _          _   if (withConversationState!= null) {
 _      _   __      ____// Delete the_conversationState for the_current conversation to_prevent the
_  _ _  __              // bot from getting_stuck in a error-loop caused by_being in a bad state.
__  _   _       _       // ConversationState_should_be thought_of as similar to_"cookie-state" in_a
 _  _ _ _ _      __     // Web pages.
 ____  _  _  _  __     _return withConversationState.delete(turnContext)
 _   _         _           .exceptionally(deleteException -> {
   _ _   _ __     _ _       __  