toJson method
Converts this Err to a JSON map. Includes breadcrumbs only when the list is non-empty so existing consumers see no extra fields.
Implementation
Map<String, dynamic> toJson() {
final model = toModel();
return {
if (model.type != null) 'type': model.type,
if (model.error != null) 'error': model.error,
if (model.statusCode != null) 'statusCode': model.statusCode,
if (model.stackTrace != null) 'stackTrace': model.stackTrace,
if (breadcrumbs.isNotEmpty) 'breadcrumbs': breadcrumbs,
};
}