forked from huysentruitw/SapNwRfc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSapLibraryNotFoundException.cs
80 lines (72 loc) · 3.17 KB
/
SapLibraryNotFoundException.cs
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
73
74
75
76
77
78
79
80
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
namespace SapNwRfc.Exceptions
{
/// <summary>
/// Exception throw when the SAP library was not found.
/// </summary>
public sealed class SapLibraryNotFoundException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="SapLibraryNotFoundException"/> class.
/// </summary>
/// <param name="innerException">The inner exception.</param>
public SapLibraryNotFoundException(Exception innerException)
: base(BuildMessage(), innerException)
{
}
[ExcludeFromCodeCoverage]
private static string BuildMessage()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return BuildWindowsMessage();
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return BuildMaxOsMessage();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
return BuildLinuxMessage();
return null;
}
private static string BuildWindowsMessage()
{
var message = new StringBuilder();
message.AppendLine("The SAP RFC libraries were not found in the output folder or in a folder contained in the systems PATH environment variable.");
message.AppendLine();
message.AppendLine("Required files for Windows:");
message.AppendLine(" sapnwrfc.dll");
message.AppendLine(" icudtXX.dll");
message.AppendLine(" icuinXX.dll");
message.AppendLine(" icuucXX.dll");
message.AppendLine();
message.AppendLine("Also make sure the 64-bit version of the Visual C++ 2013 Redistributable is installed");
return message.ToString();
}
[ExcludeFromCodeCoverage]
private static string BuildMaxOsMessage()
{
var message = new StringBuilder();
message.AppendLine("The SAP RFC libraries were not found in the output folder or in a folder contained in the systems DYLD_LIBRARY_PATH environment variable.");
message.AppendLine();
message.AppendLine("Required files for macOS:");
message.AppendLine(" libsapnwrfc.dylib");
message.AppendLine(" libicudata.XX.dylib");
message.AppendLine(" libicui18n.XX.dylib");
message.AppendLine(" libicuuc.XX.dylib");
return message.ToString();
}
[ExcludeFromCodeCoverage]
private static string BuildLinuxMessage()
{
var message = new StringBuilder();
message.AppendLine("The SAP RFC libraries were not found in the output folder or in a folder contained in the systems LD_LIBRARY_PATH environment variable.");
message.AppendLine();
message.AppendLine("Required files for Linux:");
message.AppendLine(" libsapnwrfc.so");
message.AppendLine(" libicudata.so.XX");
message.AppendLine(" libicui18n.so.XX");
message.AppendLine(" libicuuc.so.XX");
return message.ToString();
}
}
}