File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed
app-auth/graphapponlytutorial Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 44# <ProgramSnippet>
55import asyncio
66import configparser
7+ from msgraph .generated .models .o_data_errors .o_data_error import ODataError
78from graph import Graph
89
910async def main ():
@@ -30,16 +31,21 @@ async def main():
3031 except ValueError :
3132 choice = - 1
3233
33- if choice == 0 :
34- print ('Goodbye...' )
35- elif choice == 1 :
36- await display_access_token (graph )
37- elif choice == 2 :
38- await list_users (graph )
39- elif choice == 3 :
40- await make_graph_call (graph )
41- else :
42- print ('Invalid choice!\n ' )
34+ try :
35+ if choice == 0 :
36+ print ('Goodbye...' )
37+ elif choice == 1 :
38+ await display_access_token (graph )
39+ elif choice == 2 :
40+ await list_users (graph )
41+ elif choice == 3 :
42+ await make_graph_call (graph )
43+ else :
44+ print ('Invalid choice!\n ' )
45+ except ODataError as odata_error :
46+ print ('Error:' )
47+ if odata_error .error :
48+ print (odata_error .error .code , odata_error .error .message )
4349# </ProgramSnippet>
4450
4551# <DisplayAccessTokenSnippet>
@@ -53,7 +59,7 @@ async def list_users(graph: Graph):
5359 users_page = await graph .get_users ()
5460
5561 # Output each users's details
56- if users_page is not None and users_page .value is not None :
62+ if users_page and users_page .value :
5763 for user in users_page .value :
5864 print ('User:' , user .display_name )
5965 print (' ID:' , user .id )
Original file line number Diff line number Diff line change @@ -576,5 +576,5 @@ preferred-modules=
576576
577577# Exceptions that will emit a warning when being caught. Defaults to
578578# "BaseException, Exception".
579- overgeneral-exceptions =BaseException,
580- Exception
579+ overgeneral-exceptions =builtins. BaseException,
580+ builtins. Exception
You can’t perform that action at this time.
0 commit comments