Turned on the error handling in commandhandler
Showing
1 changed file
with
23 additions
and
23 deletions
... | @@ -32,29 +32,29 @@ class CommandHandler(object): | ... | @@ -32,29 +32,29 @@ class CommandHandler(object): |
32 | locals()['tokens'] = tokens | 32 | locals()['tokens'] = tokens |
33 | 33 | ||
34 | locals()['next_command'] = None | 34 | locals()['next_command'] = None |
35 | # try: | 35 | try: |
36 | if cmd in utils.load_object_from_file('rooms/' + players[id]["room"] + '.json').get('exits'): | 36 | if cmd in utils.load_object_from_file('rooms/' + players[id]["room"] + '.json').get('exits'): |
37 | params = cmd + " " + params.lower().strip() | 37 | params = cmd + " " + params.lower().strip() |
38 | cmd = "go" | 38 | cmd = "go" |
39 | if cmd == '': | 39 | if cmd == '': |
40 | return True | ||
41 | command = cmd | ||
42 | ldict = locals() | ||
43 | with open('commands/{}.txt'.format(cmd), 'r', encoding='utf-8') as f: | ||
44 | command_text = f.read() | ||
45 | exec(command_text, globals(), ldict) | ||
46 | del command_text | ||
47 | if ldict['next_command'] != None: | ||
48 | locals()['tokens'] = [] | ||
49 | tokens = [] | ||
50 | with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f: | ||
51 | exec(f.read()) | ||
52 | del ldict | ||
40 | return True | 53 | return True |
41 | command = cmd | 54 | except Exception as e: |
42 | ldict = locals() | 55 | print('Something happened...') |
43 | with open('commands/{}.txt'.format(cmd), 'r', encoding='utf-8') as f: | 56 | print(e) |
44 | command_text = f.read() | 57 | mud.send_message(id, "Unknown command '{}'".format(cmd)) |
45 | exec(command_text, globals(), ldict) | 58 | return False |
46 | del command_text | ||
47 | if ldict['next_command'] != None: | ||
48 | locals()['tokens'] = [] | ||
49 | tokens = [] | ||
50 | with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f: | ||
51 | exec(f.read()) | ||
52 | del ldict | ||
53 | return True | ||
54 | # except Exception as e: | ||
55 | # print('Something happened...') | ||
56 | # print(e) | ||
57 | # mud.send_message(id, "Unknown command '{}'".format(cmd)) | ||
58 | # return False | ||
59 | 59 | ||
60 | 60 | ... | ... |
-
Please register or sign in to post a comment