/// <summary> /// Constructs a new exception of the given type based on the given /// message, the formatting arguments and the current sequence point. /// information. /// </summary> /// <param name="location">The current location.</param> /// <param name="exception">The inner exception.</param> /// <returns> /// A new <see cref="InternalCompilerException"/> with an inner exception of /// <paramref name="exception"/>. Includes detailed origin information about /// the current source location at which this exception has been created. /// </returns> public static InternalCompilerException GetException( this ILocation location, Exception exception) { var message = (location?.FormatErrorMessage( ErrorMessages.InternalCompilerError)) ?? ErrorMessages.InternalCompilerError; return(new InternalCompilerException(message, exception)); }
/// <summary> /// Constructs a new exception of the given type based on the given /// message, the formatting arguments and the current sequence point. /// information. /// </summary> /// <param name="location">The current location.</param> /// <param name="message">The error message.</param> /// <returns> /// A new exception of type <typeparamref name="TException"/> with detailed /// origin information about the current source location at which this exception /// has been created. /// </returns> public static TException GetException <TException>( this ILocation location, string message) where TException : Exception { message = (location?.FormatErrorMessage( message ?? ErrorMessages.InternalCompilerError)) ?? ErrorMessages.InternalCompilerError; return(Activator.CreateInstance(typeof(TException), message) as TException); }