@@ -81,93 +81,68 @@ class PlotlyEmptyDataError(PlotlyError):
8181
8282# Graph Objects Errors
8383class PlotlyGraphObjectError (PlotlyError ):
84- def __init__ (self , message = '' , path = (), note = '' , plain_message = '' ):
84+ def __init__ (self , message = '' , path = (), notes = () , plain_message = '' ):
8585 self .message = message
8686 self .plain_message = plain_message
8787 self .path = list (path )
88- self .note = note
88+ self .notes = notes
8989 super (PlotlyGraphObjectError , self ).__init__ (message )
9090
9191 def __str__ (self ):
9292 format_dict = {
9393 'message' : self .message ,
9494 'path' : '[' + '][' .join (repr (k ) for k in self .path ) + ']' ,
95- 'note ' : self .note
95+ 'notes ' : ' \n ' . join ( self .notes )
9696 }
9797 message = '{message}\n \n Path To Error: {path}' .format (** format_dict )
98- if format_dict ['note ' ]:
99- message += '\n \n Additional Notes:\n {note }' .format (** format_dict )
98+ if format_dict ['notes ' ]:
99+ message += '\n \n Additional Notes:\n \n {notes }' .format (** format_dict )
100100 return message
101101
102102
103103class PlotlyDictKeyError (PlotlyGraphObjectError ):
104- def __init__ (self , obj , path = (), ** kwargs ):
105- key = path [- 1 ]
106- message = (
107- "Invalid key, '{key}', for class, '{obj_name}'.\n \n Run "
108- "'help(plotly.graph_objs.{obj_name})' for more information."
109- "" .format (key = key , obj_name = obj .__class__ .__name__ )
104+ def __init__ (self , obj , path , notes = ()):
105+ format_dict = {'attribute' : path [- 1 ], 'object_name' : obj ._name }
106+ message = ("'{attribute}' is not allowed in '{object_name}'"
107+ .format (** format_dict ))
108+ notes = [obj .help (return_help = True )] + list (notes )
109+ super (PlotlyDictKeyError , self ).__init__ (
110+ message = message , path = path , notes = notes , plain_message = message
110111 )
111- plain_message = ("Invalid key, '{key}', found in '{obj}' object"
112- "" .format (key = key , obj = obj .__class__ .__name__ ))
113- super (PlotlyDictKeyError , self ).__init__ (message = message ,
114- path = path ,
115- plain_message = plain_message ,
116- ** kwargs )
117112
118113
119114class PlotlyDictValueError (PlotlyGraphObjectError ):
120- def __init__ (self , obj , value , val_types , path = (), ** kwargs ):
121- key = path [- 1 ]
122- message = (
123- "Invalid value type, '{value_name}', associated with key, "
124- "'{key}', for class, '{obj_name}'.\n Valid types for this key "
125- "are:\n '{val_types}'.\n \n "
126- "Run 'help(plotly.graph_objs.{obj_name})' for more information."
127- .format (key = key , value_name = value .__class__ .__name__ ,
128- val_types = val_types , obj_name = obj .__class__ .__name__ )
115+ def __init__ (self , obj , path , notes = ()):
116+ format_dict = {'attribute' : path [- 1 ], 'object_name' : obj ._name }
117+ message = ("'{attribute}' has invalid value inside '{object_name}'"
118+ .format (** format_dict ))
119+ notes = [obj .help (path [- 1 ], return_help = True )] + list (notes )
120+ super (PlotlyDictValueError , self ).__init__ (
121+ message = message , plain_message = message , notes = notes , path = path
129122 )
130- plain_message = ("Invalid value found in '{obj}' associated with key, "
131- "'{key}'" .format (key = key , obj = obj .__class__ .__name__ ))
132- super (PlotlyDictValueError , self ).__init__ (message = message ,
133- plain_message = plain_message ,
134- path = path ,
135- ** kwargs )
136123
137124
138125class PlotlyListEntryError (PlotlyGraphObjectError ):
139- def __init__ (self , obj , path = (), ** kwargs ):
140- index = path [- 1 ]
141- message = (
142- "The entry at index, '{0}', is invalid in a '{1}' object"
143- "" .format (index , obj .__class__ .__name__ )
126+ def __init__ (self , obj , path , notes = ()):
127+ format_dict = {'index' : path [- 1 ], 'object_name' : obj ._name }
128+ message = ("Invalid entry found in '{object_name}' at index, '{index}'"
129+ .format (** format_dict ))
130+ notes = [obj .help (return_help = True )] + list (notes )
131+ super (PlotlyListEntryError , self ).__init__ (
132+ message = message , plain_message = message , path = path , notes = notes
144133 )
145- plain_message = (
146- "Invalid entry found in '{obj}' object at index, '{index}'."
147- "" .format (obj = obj .__class__ .__name__ , index = index )
148- )
149- super (PlotlyListEntryError , self ).__init__ (message = message ,
150- plain_message = plain_message ,
151- path = path ,
152- ** kwargs )
153134
154135
155136class PlotlyDataTypeError (PlotlyGraphObjectError ):
156- def __init__ (self , obj , path = (), ** kwargs ):
157- index = path [- 1 ]
158- message = (
159- "The entry at index, '{0}', is invalid because it does not "
160- "contain a valid 'type' key-value. This is required for valid "
161- "'{1}' lists." .format (index , obj .__class__ .__name__ )
137+ def __init__ (self , obj , path , notes = ()):
138+ format_dict = {'index' : path [- 1 ], 'object_name' : obj ._name }
139+ message = ("Invalid entry found in '{object_name}' at index, '{index}'"
140+ .format (** format_dict ))
141+ note = "It's invalid because it does't contain a valid 'type' value."
142+ notes = [note ] + list (notes )
143+ super (PlotlyDataTypeError , self ).__init__ (
144+ message = message , plain_message = message , path = path , notes = notes
162145 )
163- plain_message = (
164- "Invalid entry found in 'data' object at index, '{0}'. It "
165- "does not contain a valid 'type' key, required for 'data' "
166- "lists." .format (index ))
167- super (PlotlyDataTypeError , self ).__init__ (message = message ,
168- plain_message = plain_message ,
169- path = path ,
170- ** kwargs )
171146
172147
173148# Local Config Errors
0 commit comments