11using SqlServerSimulator . Parser ;
2- using System . Collections . Immutable ;
2+ using SqlServerSimulator . Parser . Tokens ;
33using System . Data . Common ;
44using System . Globalization ;
55
@@ -18,25 +18,25 @@ internal SimulatedSqlException(string? message)
1818 {
1919 }
2020
21- internal SimulatedSqlException ( string message , int number , byte @class , byte state )
21+ private SimulatedSqlException ( string message , int number , byte @class , byte state )
2222 : this ( message , new SimulatedSqlError ( message , number , @class , state ) )
2323 {
2424 }
2525
26- internal SimulatedSqlException ( string ? message , params ReadOnlySpan < SimulatedSqlError > errors )
26+ private SimulatedSqlException ( string ? message , params ReadOnlySpan < SimulatedSqlError > errors )
2727 : base ( message ?? "Simulated exception with no message." )
2828 {
2929 base . HResult = unchecked ( ( int ) 0x80131904 ) ;
3030 base . Source = "Core Microsoft SqlClient Data Provider" ;
3131
3232 if ( errors . Length == 0 )
3333 {
34- this . Errors = ImmutableArray . Create ( [ new SimulatedSqlError ( base . Message , 0 , 0 , 0 ) ] ) ;
34+ this . Errors = [ new SimulatedSqlError ( base . Message , 0 , 0 , 0 ) ] ;
3535
3636 return ;
3737 }
3838
39- this . Errors = ImmutableArray . Create ( errors ) ;
39+ this . Errors = [ .. errors ] ;
4040
4141 var firstError = errors [ 0 ] ;
4242
@@ -84,5 +84,13 @@ internal SimulatedSqlException(string? message, params ReadOnlySpan<SimulatedSql
8484
8585 public IReadOnlyList < SimulatedSqlError > Errors { get ; }
8686
87+ internal static SimulatedSqlException InvalidColumnName ( string name ) => new ( $ "Invalid column name '{ name } '.", 207 , 16 , 1 ) ;
88+
89+ internal static SimulatedSqlException InvalidColumnName ( IEnumerable < string > name ) => InvalidColumnName ( string . Join ( '.' , name ) ) ;
90+
91+ internal static SimulatedSqlException InvalidObjectName ( StringToken name ) => new ( $ "Invalid object name { name } .", 208 , 16 , 1 ) ;
92+
8793 internal static SimulatedSqlException SyntaxErrorNear ( Token token ) => new ( $ "Incorrect syntax near '{ token } '.", 102 , 15 , 1 ) ;
94+
95+ internal static SimulatedSqlException ThereIsAlreadyAnObject ( string name ) => new ( $ "There is already an object named '{ name } ' in the database.", 2714 , 16 , 6 ) ;
8896}
0 commit comments