public StorageException BuildException(Exception origin, string queryText) { var sqlExceptionInfo = driver.GetExceptionInfo(origin); var storageExceptionInfo = GetStorageExceptionInfo(sqlExceptionInfo); var builder = new StringBuilder(Strings.SqlErrorOccured); if (storageExceptionInfo != null) { var storageErrorDetails = storageExceptionInfo.ToString(); if (!string.IsNullOrEmpty(storageErrorDetails)) { builder.AppendLine(); builder.AppendFormat(Strings.StorageErrorDetailsX, storageErrorDetails); } } var sqlErrorDetails = sqlExceptionInfo.ToString(); if (!string.IsNullOrEmpty(sqlErrorDetails)) { builder.AppendLine(); builder.AppendFormat(Strings.SqlErrorDetailsX, sqlErrorDetails); } if (!string.IsNullOrEmpty(queryText) && includeSqlInExceptions) { builder.AppendLine(); builder.AppendFormat(Strings.QueryX, queryText); } var sqlMessage = origin.Message; if (!string.IsNullOrEmpty(sqlMessage)) { builder.AppendLine(); builder.AppendFormat(Strings.OriginalMessageX, sqlMessage); } var storageException = CreateStorageException(sqlExceptionInfo.Type, builder.ToString(), origin); storageException.Info = storageExceptionInfo; return(storageException); }