弄清楚可以抛出的所有可能的异常?(Figure out all possible exceptions that can be thrown?)
是否有可能找出可能抛出的所有可能的异常,这些异常不一定由方法的签名列出。
有2例
1)不必声明的运行时异常(显然有些是显而易见的,例如空指针,但是还有其他运行时异常我想要捕获,这可能是由于数据不好,在开发过程中我不喜欢还不知道数据不好。
2)异常是签名中列出的异常的子类。
动机的例子
想象一下我在HttpURLConnection对象上调用getInputStream(),它会抛出java.io.Exception,但实际上,它会抛出其他异常,这些异常是java.io.Exception(ala java.io.FileNotFoundException)的sublcasses,我想要的以独特的方式处理(即不想将所有java.io.Exceptions混为一谈)。
所以虽然我可以通过捕获java.io.Exception并打印出实际的异常,然后修改代码来处理这种情况,在实践中学习,但是想知道是否有更好的方法:)
谢谢
编辑:我认为人们错过了我的第二个问题。 抛出与方法签名完全一致的已检查异常的方法,但由于方法的签名仅具有某种基类,因此未在其中列出。
Is it possible to figure out all possible exceptions that can be thrown that are not necessarily listed by the method's signature.
There are 2 cases
1) runtime exceptions that don't have to be declared (obviously some are obvious, such as null pointer, but there are other runtime exceptions that I'd want to catch that can be due to bad data, which while in development I don't know is bad data yet).
2) exceptions that are subclasses of the exception listed in the signature.
a motivation example
imagine I call getInputStream() on an HttpURLConnection object, it throws java.io.Exception, but in reality, it throws other exceptions that are sublcasses of java.io.Exception (ala java.io.FileNotFoundException), which I'd want to handle in a unique manner (i.e. don't want to lump all java.io.Exceptions together).
so while I can learn in practice by catching java.io.Exception and printing out the actual exception, and then modifying code to handle that case, was wondering if there was a better method :)
thanks
edit: I think people are missing my 2nd problem. Methods that throw checked exceptions that are fully consistent with the method's signature, but aren't listed in it due to the method's signature only having some sort of base class.
原文:
最满意答案
Angular即将发生变化! 在官方Angular回购中查看此GitHub问题 。
TL; DR
什么是非常好的:有了角度4.1的第一个测试版(作为本周4.0.0的后续版本发布),您可以执行以下操作:
class MyCmp { constructor(private _builder: AnimationBuilder) { } myMethod() { const animation = this._builder.build([ style(...), animate(...), group([ animate(...) animate(...) animate(...) ]) ]); const player = animation.create(someElement); player.play(); } }
Changes are coming to Angular! See this GitHub issue in the official Angular repo.
TL;DR
What's really good: With the first beta of angular 4.1 (which comes out as the follow-up release to this weeks 4.0.0) you can do the following:
class MyCmp { constructor(private _builder: AnimationBuilder) { } myMethod() { const animation = this._builder.build([ style(...), animate(...), group([ animate(...) animate(...) animate(...) ]) ]); const player = animation.create(someElement); player.play(); } }
相关问答
更多-
不要使用相对路径 - 而是根据您在执行Get请求时从服务器中检索元素的方式使用路径。 假设AngularApp位于项目的顶层(默认情况下与Controllers或Scripts文件夹相同的树缩进),请使用以下内容作为templateURL而不是相对路径。 “/AngularApp/Templates/main.html” Don't use relative pathing - rather, path according to how you'd expect to retrieve the elemen ...
-
由例如addEventListener()附加的DOM事件处理程序或jqLite / jQuery方法bind和on在当前Angular上下文之外执行,不会触发摘要循环。 你必须使用例如$ apply手动完成: $ apply()用于从角度框架外部以角度执行表达式。 (例如,来自浏览器DOM事件,setTimeout,XHR或第三方库)。 因为我们正在调用角度框架,所以我们需要执行异常处理的适当范围生命周期,执行手表。 例: element.bind("click", function() { scop ...
-
检测$ last的指令不适用于angular.js中的ng-if(A directive to detect $last is not working with ng-if in angular.js)[2022-06-13]
目前, $last适用于按date排序的数组feeds 。 ng-if控制是否呈现每个项目,但实际上并不过滤列表。 为了按照$last将按要求运行的方式过滤列表,删除ng-if并使用Angular的过滤器 。 filter根据show函数从feeds数组中选择项的子集,并将它们作为新数组返回。 新数组仅包含show函数返回true元素。这是Codepen链接的解决方案 JS: var myApp = angular.module('flyingCartApp', []); myApp.directive('addToCartButton', function() { function link(scope, element, attributes) { element.on('click', function(event){ var cartElem = angular.element(document.ge ...无法运行ngAnimate动画(Can't run ngAnimate animation)[2021-09-03]
更改至你在div上有两个类声明。 也许你想做ng-class = {'fadein fadeout':! collapsed}。 使用plunkr: https ://plnkr.co/edit/MsgJxp ? p = preview 检查此 ...没有必要在你的指令中注入'angularGrid'(并且没有这样的可注入元素)。 所有已注册的指令只要在角度模块中注册,即可用于所有模板。 你需要的唯一东西是添加'agGrid'到你的角度模块的依赖关系类似var module = angular.module("example", ["agGrid"]); 那么你在你的模板和指令中使用了ag-grid。 有关更多详细信息,请参阅ag-grid文档 。 所以从行app.directive('inApptConflict', ['angularGrid', f ...正如泰勒在评论中提出的那样,我正在单独提出答案 我在这里找到了解决方案: 感谢mohamedrias 所以工作代码看起来像这样: export class ContentDirective implements angular.IDirective { public priority = 10; public restrict = 'A'; static $inject = [ "$window" ]; constructor(private $window) { } public lin ...更新 我只为前向和后向创建了两个动画,并在上一个动画的onComplete回调结束时开始一次运行。 Plunker class AnimateBox { //animation: Animation; //a:Animation; constructor(private _ab: AnimationBuilder, private _e: ElementRef) {} createAnimation:Function = (forward:boolean, count:num ...Angular即将发生变化! 在官方Angular回购中查看此GitHub问题 。 TL; DR 什么是非常好的:有了角度4.1的第一个测试版(作为本周4.0.0的后续版本发布),您可以执行以下操作: class MyCmp { constructor(private _builder: AnimationBuilder) { } myMethod() { const animation = this._builder.build([ style(...), ...应该工作,除了Angular模板区分大小写 selector: '[Slidernav]' ...Some content应该是 selector: '[Slidernav]' ...Some content要么 selector: '[slidernav]' ...Some content除此之外,您可能希望使用具有模板的组件 template: '相关文章
更多- com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
- 解决Hadoop抛出的Task process exit with nonzero status of 134异常
- Java 异常处理
- 在web应用中如何对异常进行处理
- Lua 异常处理
- Hadoop 异常处理
- tomcat6启动异常 Could not load com.mysql.jdbc.SQLError的解决方法
- java异常处理分类
- Cheatsheet: 2011 04.11 ~ 04.19
- java Exception异常处理实例
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。