Blame view

netcore/src/Infrastructure/NCC/ViewEngine/Exceptions/ViewEngineTemplateException.cs 1.5 KB
de2bd2f9   “wangming”   项目初始化
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
  using NCC.Dependency;
  using Microsoft.CodeAnalysis;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  
  namespace NCC.ViewEngine
  {
      /// <summary>
      /// 视图引擎模板编译异常类
      /// </summary>
      [SuppressSniffer]
      public class ViewEngineTemplateException : ViewEngineException
      {
          /// <summary>
          /// 构造函数
          /// </summary>
          public ViewEngineTemplateException()
          {
          }
  
          /// <summary>
          /// 构造函数
          /// </summary>
          /// <param name="info"></param>
          /// <param name="context"></param>
          protected ViewEngineTemplateException(SerializationInfo info, StreamingContext context) : base(info, context)
          {
          }
  
          /// <summary>
          /// 构造函数
          /// </summary>
          /// <param name="innerException"></param>
          public ViewEngineTemplateException(Exception innerException) : base(null, innerException)
          {
          }
  
          /// <summary>
          /// 错误信息
          /// </summary>
          public List<Diagnostic> Errors { get; set; }
  
          /// <summary>
          /// 生成的代码
          /// </summary>
          public string GeneratedCode { get; set; }
  
          /// <summary>
          /// 重写异常消息
          /// </summary>
          public override string Message => $"Unable to compile template: {string.Join("\n", Errors.Where(w => w.IsWarningAsError || w.Severity == DiagnosticSeverity.Error))}";
      }
  }