Map<String, dynamic> toJson() => { if (type != null) 'type': type, if (reason != null) 'reason': reason, if (error != null) 'error': error!.toJson(), };