function str = all_causes(ME)
% get all causes and make a nice string to display

str = '';

if ~isempty(ME.cause)
    str = sprintf('%s\n%s',str,ME.message);
    for ii=1:numel(ME.cause)
        str = sprintf('%s\n%s',str,all_causes(ME.cause{ii})); %recursive call (!)
    end
else
    str = ME.message;
end
return