diff --git a/samples/05.multi-turn-prompt/app.py b/samples/05.multi-turn-prompt/app.py index 2a358711d..790c2019c 100644 --- a/samples/05.multi-turn-prompt/app.py +++ b/samples/05.multi-turn-prompt/app.py @@ -4,7 +4,6 @@ import asyncio import sys from datetime import datetime -from types import MethodType from flask import Flask, request, Response from botbuilder.core import ( @@ -59,7 +58,9 @@ async def on_error(context: TurnContext, error: Exception): # Clear out state await CONVERSATION_STATE.delete(context) -ADAPTER.on_turn_error = MethodType(on_error, ADAPTER) +# Set the error handler on the Adapter. +# In this case, we want an unbound method, so MethodType is not needed. +ADAPTER.on_turn_error = on_error # Create MemoryStorage, UserState and ConversationState MEMORY = MemoryStorage() diff --git a/samples/06.using-cards/app.py b/samples/06.using-cards/app.py index 611090cb6..fe0c69b56 100644 --- a/samples/06.using-cards/app.py +++ b/samples/06.using-cards/app.py @@ -7,7 +7,6 @@ import asyncio import sys from datetime import datetime -from types import MethodType from flask import Flask, request, Response from botbuilder.core import ( @@ -35,7 +34,7 @@ # Catch-all for errors. -async def on_error(self, context: TurnContext, error: Exception): +async def on_error(context: TurnContext, error: Exception): # This check writes out errors to console log .vs. app insights. # NOTE: In production environment, you should consider logging this to Azure # application insights. @@ -61,7 +60,9 @@ async def on_error(self, context: TurnContext, error: Exception): # Clear out state await CONVERSATION_STATE.delete(context) -ADAPTER.on_turn_error = MethodType(on_error, ADAPTER) +# Set the error handler on the Adapter. +# In this case, we want an unbound method, so MethodType is not needed. +ADAPTER.on_turn_error = on_error # Create MemoryStorage, UserState and ConversationState MEMORY = MemoryStorage() diff --git a/samples/21.corebot-app-insights/app.py b/samples/21.corebot-app-insights/app.py index 9cc6896be..5011c21f9 100644 --- a/samples/21.corebot-app-insights/app.py +++ b/samples/21.corebot-app-insights/app.py @@ -14,7 +14,6 @@ import asyncio import sys from datetime import datetime -from types import MethodType from flask import Flask, request, Response from botbuilder.core import ( @@ -45,7 +44,7 @@ # Catch-all for errors. -async def on_error(self, context: TurnContext, error: Exception): +async def on_error(context: TurnContext, error: Exception): # This check writes out errors to console log .vs. app insights. # NOTE: In production environment, you should consider logging this to Azure # application insights. @@ -69,10 +68,11 @@ async def on_error(self, context: TurnContext, error: Exception): await context.send_activity(trace_activity) # Clear out state - nonlocal self await CONVERSATION_STATE.delete(context) -ADAPTER.on_turn_error = MethodType(on_error, ADAPTER) +# Set the error handler on the Adapter. +# In this case, we want an unbound method, so MethodType is not needed. +ADAPTER.on_turn_error = on_error # Create MemoryStorage, UserState and ConversationState MEMORY = MemoryStorage() diff --git a/samples/44.prompt-users-for-input/app.py b/samples/44.prompt-users-for-input/app.py index 9e598f407..79b861b59 100644 --- a/samples/44.prompt-users-for-input/app.py +++ b/samples/44.prompt-users-for-input/app.py @@ -4,7 +4,6 @@ import asyncio import sys from datetime import datetime -from types import MethodType from flask import Flask, request, Response from botbuilder.core import ( @@ -31,7 +30,7 @@ # Catch-all for errors. -async def on_error(self, context: TurnContext, error: Exception): +async def on_error(context: TurnContext, error: Exception): # This check writes out errors to console log .vs. app insights. # NOTE: In production environment, you should consider logging this to Azure # application insights. @@ -57,7 +56,9 @@ async def on_error(self, context: TurnContext, error: Exception): # Clear out state await CONVERSATION_STATE.delete(context) -ADAPTER.on_turn_error = MethodType(on_error, ADAPTER) +# Set the error handler on the Adapter. +# In this case, we want an unbound method, so MethodType is not needed. +ADAPTER.on_turn_error = on_error # Create MemoryStorage and state MEMORY = MemoryStorage() diff --git a/samples/45.state-management/app.py b/samples/45.state-management/app.py index 1268ffcd2..4609c2881 100644 --- a/samples/45.state-management/app.py +++ b/samples/45.state-management/app.py @@ -4,7 +4,6 @@ import asyncio import sys from datetime import datetime -from types import MethodType from flask import Flask, request, Response from botbuilder.core import ( @@ -31,7 +30,7 @@ # Catch-all for errors. -async def on_error(self, context: TurnContext, error: Exception): +async def on_error(context: TurnContext, error: Exception): # This check writes out errors to console log .vs. app insights. # NOTE: In production environment, you should consider logging this to Azure # application insights. @@ -57,7 +56,9 @@ async def on_error(self, context: TurnContext, error: Exception): # Clear out state await CONVERSATION_STATE.delete(context) -ADAPTER.on_turn_error = MethodType(on_error, ADAPTER) +# Set the error handler on the Adapter. +# In this case, we want an unbound method, so MethodType is not needed. +ADAPTER.on_turn_error = on_error # Create MemoryStorage and state MEMORY = MemoryStorage()