forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionTestBoundObject.cs
More file actions
72 lines (65 loc) · 2.13 KB
/
ExceptionTestBoundObject.cs
File metadata and controls
72 lines (65 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace CefSharp.Example
{
public class ExceptionTestBoundObject
{
[DebuggerStepThrough]
private double DivisionByZero(int zero)
{
return 10 / zero;
}
[DebuggerStepThrough]
public double TriggerNestedExceptions()
{
try
{
try
{
return DivisionByZero(0);
}
catch (Exception innerException)
{
throw new InvalidOperationException("Nested Exception Invalid", innerException);
}
} catch (Exception e)
{
throw new OperationCanceledException("Nested Exception Canceled", e);
}
}
[DebuggerStepThrough]
public int TriggerParameterException(int parameter)
{
return parameter;
}
public void TestCallbackException(IJavascriptCallback errorCallback, IJavascriptCallback errorCallbackResult)
{
const int taskDelay = 500;
Task.Run(async () =>
{
await Task.Delay(taskDelay);
using (errorCallback)
{
JavascriptResponse result = await errorCallback.ExecuteAsync("This callback from C# was delayed " + taskDelay + "ms");
string resultMessage;
if (result.Success)
{
resultMessage = "Fatal: No Exception thrown in error callback";
}
else
{
resultMessage = "Exception Thrown: " + result.Message;
}
await errorCallbackResult.ExecuteAsync(resultMessage);
}
});
}
}
}