// Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the Apache 2.0 License.// See the LICENSE file in the project root for more information.using System;namespace IronPythonTest {public class ExceptionsTest {// a call that takes the fast pathpublic void CallVirtual() {VirtualFunc();}public virtual void VirtualFunc() {// a virtual function we can override for throwing from Python code}// overloads forced to take the slow path...public void CallVirtualOverloaded(int bar) {VirtualFunc();}public void CallVirtualOverloaded(string s) {VirtualFunc();}public void CallVirtualOverloaded(object foo) {VirtualFunc();}public void ThrowException() {throw new IndexOutOfRangeException("Index out of range!");}public object CallVirtCatch() {try {CallVirtual();} catch (Exception e) {return e;}return null;}public object CatchAndRethrow() {try {CallVirtual();} catch (Exception e) {#pragma warning disable CA2200 // Rethrow to preserve stack detailsthrow e;#pragma warning restore CA2200 // Rethrow to preserve stack details}return null;}public object CatchAndRethrow2() {try {CallVirtual();} catch (Exception) {throw;}return null;}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。