@@ -20,6 +20,7 @@ package imapsql
2020
2121import (
2222 "context"
23+ "errors"
2324 "runtime/trace"
2425
2526 "github.com/emersion/go-imap"
@@ -78,10 +79,11 @@ func (d *delivery) AddRcpt(ctx context.Context, rcptTo string, _ smtp.RcptOption
7879 userHeader .Add ("Delivered-To" , accountName )
7980
8081 if err := d .d .AddRcpt (accountName , userHeader ); err != nil {
81- if err == imapsql .ErrUserDoesntExists || err == backend .ErrNoSuchMailbox {
82+ if errors . Is ( err , imapsql .ErrUserDoesntExists ) || errors . Is ( err , backend .ErrNoSuchMailbox ) {
8283 return userDoesNotExist (err )
8384 }
84- if _ , ok := err .(imapsql.SerializationError ); ok {
85+ var serializationError imapsql.SerializationError
86+ if errors .As (err , & serializationError ) {
8587 return & exterrors.SMTPError {
8688 Code : 453 ,
8789 EnhancedCode : exterrors.EnhancedCode {4 , 3 , 2 },
@@ -115,11 +117,12 @@ func (d *delivery) Body(ctx context.Context, header textproto.Header, body buffe
115117
116118 if d .msgMeta .Quarantine {
117119 if err := d .d .SpecialMailbox (imap .JunkAttr , d .store .junkMbox ); err != nil {
118- if _ , ok := err .(imapsql.SerializationError ); ok {
120+ var serializationError imapsql.SerializationError
121+ if errors .As (err , & serializationError ) {
119122 return & exterrors.SMTPError {
120123 Code : 453 ,
121124 EnhancedCode : exterrors.EnhancedCode {4 , 3 , 2 },
122- Message : "Storage access serialiation problem , try again later" ,
125+ Message : "Internal server error , try again later" ,
123126 TargetName : "imapsql" ,
124127 Err : err ,
125128 }
@@ -131,11 +134,12 @@ func (d *delivery) Body(ctx context.Context, header textproto.Header, body buffe
131134 header = header .Copy ()
132135 header .Add ("Return-Path" , "<" + target .SanitizeForHeader (d .mailFrom )+ ">" )
133136 err := d .d .BodyParsed (header , body .Len (), body )
134- if _ , ok := err .(imapsql.SerializationError ); ok {
137+ var serializationError imapsql.SerializationError
138+ if errors .As (err , & serializationError ) {
135139 return & exterrors.SMTPError {
136140 Code : 453 ,
137141 EnhancedCode : exterrors.EnhancedCode {4 , 3 , 2 },
138- Message : "Storage access serialiation problem , try again later" ,
142+ Message : "Internal server error , try again later" ,
139143 TargetName : "imapsql" ,
140144 Err : err ,
141145 }
0 commit comments