捕获Exception类而不是Exception子类是不好的做法?(Is it bad practice to catch the Exception class instead of Exception sub-classes?)
我有一个抛出Exception子类的方法。 如果我为Exception的每个子类执行相同的catch功能,那么只是捕获Exceptions类或者我应该单独捕获每个异常是不好的做法吗?
I have a method which throws subclasses of Exception. If I am performing the same catch functionality for each sub-class of Exception that's causght is it bad practice to just catch the Exceptions class or should I catch each exception individually ?
原文:https://stackoverflow.com/questions/13752104
最满意答案
您应该在项呈示器的数据设置器中执行此操作:
public override function set data(val:Object):void{ super.data=val; if ((AdvancedDataGrid(listData.owner).columns[listData.columnIndex]. showDataTips)&&(textWidth>width)) toolTip=listData.label; else toolTip=null; }
I solved it. The trick is to use
validateSize
for thewidth
property.validateProperties
is for properties that don't belong to any of the other groups for which there's a dedicatedvalidateX
function (such asvalidateSize
,validateList
, etc.).
相关问答
更多-
该属性在validateProperties中仍具有旧值(The property still has the old value in validateProperties)[2023-09-24]
您应该在项呈示器的数据设置器中执行此操作: public override function set data(val:Object):void{ super.data=val; if ((AdvancedDataGrid(listData.owner).columns[listData.columnIndex]. showDataTips)&&(textWidth>width)) toolTip=listData.label; ... -
没有名为“currentCSSState”的此类属性。 但是, Spinner控件有一个stepSize属性,您可以使用该属性控制在单击按钮时微调器递增/递减的程度。 如果将stepSize设置为2,这似乎接近您正在寻找的内容。 如果希望更多地控制微调器递增/递减值的方式,可以覆盖Spinner控件的方法incrementButton_buttonDownHandler()和decrementButton_buttonDownHandler() ,这些方法在单击按钮时执行。 以下是其中一种方法的默认实现: ...
-
使用willSet并做这样的事情 enum State : Equatable { case idle case active case done(String) } class test { var x: State { willSet { if x != newValue { print("\(x) -> \(newValue)") } } } init(_ x: State) { self.x = x ...
-
好吧,我终于修好了! 结果是堆栈跟踪中的线索。 WebAPI中存在一个用于模型绑定的验证过程,在该过程中的某个位置调用了一个名为ShouldValidateType(Type type)东西。 对于我的SavingObjectGraph属性,该函数返回true,这反过来导致User to Role to User等的无限循环。 我不得不改变两个地方来排序,首先关闭class DefaultBodyModelValidator ,重写它的函数public override bool ShouldValidat ...
-
这不是财产功能; 它是从RDFa使用的属性,它是从RDF模块添加的。 删除这些属性的更简单方法是禁用模块,但我不建议这样做,因为该模块的目的是使用元数据丰富您的内容,以便让其他应用程序更好地理解其关系和属性。 或者,如果问题仅在于用于节点的属性,那么您可以实现类似于以下代码的代码: function mymodule_preprocess_node(&$variables) { if (isset($variables['title_attributes_array'])) { $variab ...
-
内存管理不是使用属性的唯一优势。 我想到的两个特别是: KVO(无需手动调用willChangeValueForKey:和didChangeValueForKey: - 参见手动更改通知 ) 能够为setter和getter编写自定义逻辑,以及为setter和getter编写子类自定义。 bbum在iOS中对此做了很好的回应:每个iVar都必须属于财产吗? Memory management is not the only advantage of using properties. Two in part ...
-
什么时候使用@property?(When to use @property?)[2022-09-01]
你是正确的,Objective-C运行时将为@property访问器增加一定的开销。 但是,这是在Objective-C类之间共享信息的可接受方式。 如果您已经测量了应用程序并确定@property开销实际上是一个处理瓶颈,那么您应该只考虑不同的方法。 请记住,现代处理器在GHz范围内运行,“每秒一百万次”发生的事情仅在MHz范围内。 机会是,你的瓶颈将在其他地方。 如果确实遇到问题,可以随时在更大的Objective-C ParticleCloud类中的一组简单Particle结构上进行粒子处理。 这将允 ... -
我怀疑这个属性应该在与RTC(Jazz或buildForge)构建关联的build.xml中定义。 注意: 此线程有类似的错误,在这种情况下,它是一个所有权问题: 使用版本3.0.1,fetch仅创建文件夹,但不会将任何文件提取到文件系统。 CRRTC3512E错误是正确的,ant文件不存在,因为未提取文件。 解决了! 构建工作区的所有者不正确。 I suspect this property should be defined in the build.xml associate with the RTC ...
-
如Objective-C功能可用性索引中所述 ,Xcode 4.4(LLVM编译器4.0)引入了属性实例变量的自动合成,并且需要现代运行时(iOS上的所有代码,OS X上的64位代码)。 所以,教程有点过时了,就是这样。 As noted in the Objective-C Feature Availability Index, automatic synthesis of property instance variables was introduced with Xcode 4.4 (LLVM Co ...
-
很简单。 找到要更新的对象,然后更新它们。 查看根对象的值,根据您的条件过滤它们,更新Properties属性,删除所需的属性。 (.[] | select(.Type == "Type2")).Properties |= del(.Property2) 在对象上使用.[]生成对象的所有属性值。 另外值得一提的是,当您使用赋值更新值时,表达式的结果只返回输入(换句话说,它不会更改上下文)。 Pretty simple. Find the objects that you want to update, t ...