@@ -81,93 +81,68 @@ class PlotlyEmptyDataError(PlotlyError):
81
81
82
82
# Graph Objects Errors
83
83
class PlotlyGraphObjectError (PlotlyError ):
84
- def __init__ (self , message = '' , path = (), note = '' , plain_message = '' ):
84
+ def __init__ (self , message = '' , path = (), notes = () , plain_message = '' ):
85
85
self .message = message
86
86
self .plain_message = plain_message
87
87
self .path = list (path )
88
- self .note = note
88
+ self .notes = notes
89
89
super (PlotlyGraphObjectError , self ).__init__ (message )
90
90
91
91
def __str__ (self ):
92
92
format_dict = {
93
93
'message' : self .message ,
94
94
'path' : '[' + '][' .join (repr (k ) for k in self .path ) + ']' ,
95
- 'note ' : self .note
95
+ 'notes ' : ' \n ' . join ( self .notes )
96
96
}
97
97
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 )
100
100
return message
101
101
102
102
103
103
class 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
110
111
)
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 )
117
112
118
113
119
114
class 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
129
122
)
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 )
136
123
137
124
138
125
class 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
144
133
)
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 )
153
134
154
135
155
136
class 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
162
145
)
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 )
171
146
172
147
173
148
# Local Config Errors
0 commit comments