4545 StatusField : http .StatusText (http .StatusInternalServerError ),
4646 ErrorField : "Unable to locate the table" ,
4747 }
48+ ErrNoSuchColumn = & herodot.DefaultError {
49+ CodeField : http .StatusInternalServerError ,
50+ GRPCCodeField : codes .Internal ,
51+ StatusField : http .StatusText (http .StatusInternalServerError ),
52+ ErrorField : "Unable to locate the column" ,
53+ }
4854)
4955
5056func handlePostgres (err error , sqlState string ) error {
@@ -56,6 +62,8 @@ func handlePostgres(err error, sqlState string) error {
5662 return errors .WithStack (ErrConcurrentUpdate .WithWrap (err ))
5763 case "42P01" : // "no such table"
5864 return errors .WithStack (ErrNoSuchTable .WithWrap (err ))
65+ case "42703" : // "no such column"
66+ return errors .WithStack (ErrNoSuchColumn .WithWrap (err ))
5967 }
6068 return errors .WithStack (err )
6169}
@@ -81,10 +89,12 @@ func HandleError(err error) error {
8189 return errors .WithStack (handlePostgres (err , e .Code ))
8290 } else if e := new (mysql.MySQLError ); errors .As (err , & e ) {
8391 switch e .Number {
84- case 1062 :
92+ case 1062 : // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_dup_entry
8593 return errors .WithStack (ErrUniqueViolation .WithWrap (err ))
86- case 1146 :
94+ case 1146 : // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_no_such_table
8795 return errors .WithStack (ErrNoSuchTable .WithWrap (e ))
96+ case 1054 : // https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_bad_field_error
97+ return errors .WithStack (ErrNoSuchColumn .WithWrap (e ))
8898 }
8999 }
90100
0 commit comments