抛出异常来停止进程(Throw exception to stop process)
有些时候在C#中我想抛出一个无法处理的异常。 导致进程停止的升级异常。 这可能吗?
Some times in C# I would like to throw an exception that cannot be handled. An escalated exception that results in the process being stopped. Is this possible?
原文:https://stackoverflow.com/questions/6762074
最满意答案
使用特征取决于两件事:
是否要对某些不依赖于
Controller
类使用RestController
方法?既然你肯定会使用一些
Controller
方法编写RestController
,我认为答案是否定的。您是否计划创建其他必须用于完成控制器的类?
如果答案是肯定的,那么您可能会将
RestController
作为Controller
继承,并将这些其他类作为特征写入。 如果答案是否定的,那么RestController
应该是中间的更清楚。Using a trait depends on 2 things :
Do you want to use
RestController
methods for some classes that doesn't depend onController
?Since you will surely use some
Controller
methods to writeRestController
, I think the answer is no.Do you plan to create others classes that you will have to use to complete your controllers ?
If the answer is yes, there are chances that you will keep
RestController
as aController
inherited one and write these others classes as traits. If the answer is no, it's even clearer thatRestController
should be an intermediary one.
相关问答
更多-
终于找到了答案谢谢@ Cerad的评论:Symfony 3的默认安装创建了services.yml文件,并将每个Controllers注册为服务。 禁用此功能允许我的控制器访问容器。 这些都是有罪的: AppBundle\Controller\: resource: '../../src/AppBundle/Controller' public: true tags: ['controller.service_a ...
-
特质实施(trait implementation)[2023-11-22]
它们在性能方面完全相同。 如果你写这样的测试: object Traits { trait A { def a = "apple" } trait B extends A { def b = "blueberry" } trait C1 extends B { def c = "cherry" } trait C2 extends A { def c = "chard" } class Dessert extends B with C1 { } class Salad extends ... -
是的,他们可以,扩展一个class的trait限制了什么classes可以扩展这个trait - 即混合在该trait所有classes必须扩展class 。 scala> class Foo defined class Foo scala> trait FooTrait extends Foo defined trait FooTrait scala> val good = new Foo with FooTrait good: Foo with FooTrait = $anon$1@773d3f62 ...
-
不要用 ,总是使用使用特征取决于两件事: 是否要对某些不依赖于Controller类使用RestController方法? 既然你肯定会使用一些Controller方法编写RestController ,我认为答案是否定的。 您是否计划创建其他必须用于完成控制器的类? 如果答案是肯定的,那么您可能会将RestController作为Controller继承,并将这些其他类作为特征写入。 如果答案是否定的,那么RestController应该是中间的更清楚。 Using a trait depends on 2 things ...你可以尝试像这样使用angular.extend : angular.extend($scope,CtrlTrait); 它将允许我们在$scope使用与您的服务相同的功能。 所以,你可以直接在你的html中使用这个函数: 这里是你的plunker演示改编: var app = angular.module('plunker', []); app.controller('Mai ...
加载嵌套的特征类(Load nested trait class)[2021-09-10]
使用$ Class.forName("test.TestTraitsUnderObject$InnerOperation") Use $ Class.forName("test.TestTraitsUnderObject$InnerOperation")Scala特征或具体类(Scala trait or concrete class)[2022-06-22]
通常情况下,没有单一的规则,但我个人认为在Odersky / Spoon / Venners的书“Scala编程”中提供了一些有用的建议。 它说如果行为不会在其他不相关的类中重用,请使用具体的类。 另一方面,如果您认为您将在不相关的地方的其他地方重复使用该行为,请将其作为特征。 As it's often the case, there is no single rule, but I personally found useful a general suggestion give in Odersky/ ...蛋糕模式:混入特征(Cake pattern: mixing in in a trait)[2023-10-28]
这是一个稍微简单的方法来遇到同样的问题: scala> trait Foo defined trait Foo scala> trait Bar { this: Foo => } defined trait Bar scala> trait Baz extends Bar:9: error: illegal inheritance; self-type Baz does not conform to Bar's selftype Bar with Foo trait ... 没有返回类型的抽象方法将返回Unit,因此您所要做的就是将Action [AnyContent]的返回类型添加到方法中。 trait RestTrait extends Controller{ /** * List entities. */ def list:play.api.mvc.Action[play.api.mvc.AnyContent] /** * Create entity. Get entity from request.body */ def cre ...相关文章
更多- java Exception异常处理实例
- 解决Hadoop抛出的Task process exit with nonzero status of 134异常
- Hadoop运行时错误:Task process exit with nonzero status of 1
- EXT4 Store Load For Gird Exception
- EXT4 Store Batch Sync Exception
- 干干净净终结进程[转] Terminate process cleanly [reprint]
- zz Data Analysis Process
- Hadoop执行分布式Process
- multi-core solr deploy process(not complete)
- multi-core solr deploy process(not complete)
最新问答
更多- 获取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的基本操作命令。。。