From 5b1661b02970aa52a45d55ef266e3fee968e84fa Mon Sep 17 00:00:00 2001 From: kbulgrien Date: Fri, 14 Nov 2008 04:44:17 +0000 Subject: [PATCH] Avoid DeprecationWarning: raising a string exception is deprecated by making a user-defined exception handler. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@10423 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/misc/npc_dialog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/misc/npc_dialog.py b/python/misc/npc_dialog.py index f08db131f..e281bcadf 100644 --- a/python/misc/npc_dialog.py +++ b/python/misc/npc_dialog.py @@ -95,6 +95,15 @@ import os from CFDialog import DialogRule, Dialog import cjson +# Avoid DeprecationWarning: raising a string exception is deprecated by making +# a user-defined exception handler. +# +class NPC_Dialog_Error(Exception): + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) + def ruleConnected(character,rule): m = character.Map m.TriggerConnected(rule.connected,1) @@ -106,7 +115,7 @@ if (Crossfire.ScriptParameters() != None): try: f = open(filename,'rb') except: - raise 'Unable to read %s' % filename + NPC_Dialog_Error('Unable to read %s' % filename) else: Crossfire.Log(Crossfire.LogDebug,"Reading from file %s" %filename) parameters=cjson.decode(f.read())