main
cs 38 lines 1.31 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Core.Native
4 {
5 using System;
6 using System.Collections.Generic;
7 using System.ComponentModel;
8 using System.Runtime.Serialization;
9
10 [Serializable]
11 internal class WixNativeException : Exception
12 {
13 private static readonly string LineSeparator = Environment.NewLine + " ";
14
15 public WixNativeException()
16 {
17 }
18
19 public WixNativeException(string message) : base(message)
20 {
21 }
22
23 public WixNativeException(string message, Exception innerException) : base(message, innerException)
24 {
25 }
26
27 protected WixNativeException(SerializationInfo info, StreamingContext context) : base(info, context)
28 {
29 }
30
31 public static WixNativeException FromOutputLines(int errorCode, IReadOnlyCollection<string> lines)
32 {
33 var exception = new Win32Exception(errorCode);
34 var output = String.Join(LineSeparator, lines);
35 return new WixNativeException($"wixnative.exe failed with error code: {exception.ErrorCode} - {exception.Message} Output:{LineSeparator}{output}", exception);
36 }
37 }
38 }