运行R脚本后打印所有错误消息的列表

时间:2016-04-12 00:01:49

标签: r error-handling

道歉,如果这个问题有明显的答案,但我还没有找到答案。

所有我正在寻找的错误等同于warnings() - 我想运行一个脚本,然后获取运行脚本时发生的所有错误的列表。

看了traceback(),好像它可能会做我想要的 - 帮助文件说“默认显示是最后一次未捕获错误的堆栈” - 但无法弄清楚如何让它返回所有未被捕获的错误,而不仅仅是最后一个错误。

1 个答案:

答案 0 :(得分:1)

我的建议是,保存脚本(例如<div class="Content-inner-pages"> <div class="TopHeading TopHeading2"> <h2>Assets</h2> @* @Html.ActionLink("Create", "Create")*@ <a class="CreateBtn AssetsBtn" href="Javascript:void(0);" onclick="javascript: HideUpdateButton();">Add Asset</a> <div class="clearfix"></div> </div> <input type="hidden" id="hdnIsNew" value="1" /> <input type="hidden" id="hdnRecId" /> <!-- Slide Popup panel --> <div class="cd-panel from-right AddAssetForm"> <header class="cd-panel-header"> <h3>Add Asset</h3> <a href="javascript:void(0);" onclick="javascript: DisplayClear();" class="cd-panel-close">Close</a> </header> <div class="cd-panel-container"> <div class="cd-panel-content"> <!-- Add Reminder --> <div class="form-horizontal form-details popup-box"> @using (Html.BeginForm("AssetsPage", "SuperAdmin", FormMethod.Post, new { enctype = "multipart/form-data" })) { <div class="form-group"> <label class="col-md-5 control-label"> Asset Title </label> @Html.TextArea("ID", "", new { @class = "form-control", @id = "ID", @style = "display:none;" }) <div class="col-md-7"> @Html.TextBox("Title", "", new { @class = "form-control", @id = "Title", required = "required" }) @Html.ValidationMessage("Title", "*") </div> </div> <div class="form-group"> <label class="col-md-5 control-label">Description</label> <div class="col-md-7"> @Html.TextArea("Description", "", new { @class = "form-control", @id = "Description", required = "required" }) @Html.ValidationMessage("Description", "*") </div> </div> <div class="form-group"> <label class="col-md-5 control-label">Attachment</label> <div class="col-md-7"> <input type="file" name="file" id="filena" class="custom-file-input" required="required"> @Html.ValidationMessage("file", "*") </div> </div> <div class="form-group"> <div class="col-md-7 col-md-offset-5"> <input type="submit" id="SaveBtn" value="Save" name="actiontype" class="btn-class btn-success"> <input type="submit" id="UpdateBtn" value="Update" name="actiontype" class="btn-class btn-success"> </div> </div> } </div><!-- End Add Reminder --> </div> <!-- cd-panel-content --> </div> <!-- cd-panel-container --> </div> <!-- cd-panel --> <div class="box"> <div class="box-content Custom-DataTable"> <table id="AdministationAssets" class="table table-hover dt-responsive CustomDatable AdministationAssetsTable" cellspacing="0" width="100%"> <thead> <tr> <th style="width:5%;">Assets</th> <th style="width:15%;"> @Html.DisplayNameFor(model => model.Title) </th> <th style="width:50%;"> @Html.DisplayNameFor(model => model.Description) </th> <th style="width:8%;">Options</th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr> <td id="target" class=""> @{ switch (item.Extenstion.ToLower()) { case "doc": <i class="fa fa-file-word-o text-primary AssetIcon"></i> break; case "docx": <i class="fa fa-file-word-o text-primary AssetIcon"></i> break; case "xls": <i class="fa fa-file-excel-o text-success AssetIcon"></i> break; case "xlsx": <i class="fa fa-file-excel-o text-success AssetIcon"></i> break; case "ppt": <i class="fa fa-file-powerpoint-o text-danger AssetIcon"></i> break; case "jpg": <i class="fa fa-file-photo-o text-warning AssetIcon"></i> break; case "png": <i class="fa fa-file-photo-o text-warning AssetIcon"></i> break; case "pdf": <i class="fa fa-file-pdf-o text-danger AssetIcon"></i> break; case "zip": <i class="fa fa-file-archive-o text-muted AssetIcon"></i> break; case "htm": <i class="fa fa-file-code-o text-info AssetIcon"></i> break; case "txt": <i class="fa fa-file-text-o text-info AssetIcon"></i> break; case "mov": <i class="fa fa-file-movie-o text-warning AssetIcon"></i> break; case "mp3": <i class="fa fa-file-audio-o text-warning AssetIcon"></i> break; default: <i class="fa fa-file AssetIcon"></i> break; } } </td> <td> @Html.DisplayFor(modelItem => item.Title) </td> <td> @Html.DisplayFor(modelItem => item.Description) </td> <td> @Html.ActionLink("Download", "DownloadAsset", new { id = item.ID }, new { @class = "ActionInvoice" }) @Html.ActionLink("Edit", "AddEditRecord", new { id = item.ID }, new { @class = "ActionEdit AssetEdit", onclick = "javascript:GetEditDetails(" + item.ID + ")" }) @Html.ActionLink("Delete", "AssetDelete", new { id = item.ID }, new { @class = "ActionDelete", onclick = "return confirm('Are You Sure delete this record?');", }) </td> </tr> } </tbody> </table> </div> </div> ),然后使用script.R运行整个脚本。这将在每个错误时停止。如果您只想查看是否存在错误,这将是一个很好的方法。