Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: installer/src/installer-lib/record.cpp

Issue 6197445574787072: Cleaned up CA exceptions. Integrated free-standing handle class. (Closed)
Patch Set: Created March 30, 2014, 7:43 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « installer/src/installer-lib/property.cpp ('k') | installer/src/installer-lib/session.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: installer/src/installer-lib/record.cpp
===================================================================
--- a/installer/src/installer-lib/record.cpp
+++ b/installer/src/installer-lib/record.cpp
@@ -2,6 +2,7 @@
* \file record.cpp Implementation of Record class.
*/
+#include "installer-lib.h"
#include "record.h"
#include "msiquery.h"
@@ -13,7 +14,7 @@
_handle = MsiCreateRecord( n_fields ) ;
if ( ! _handle )
{
- throw std::runtime_error( "Failed to create record" ) ;
+ throw windows_api_error( "MsiCreateRecord", 0 ) ;
}
}
@@ -51,8 +52,8 @@
*/
std::wstring Record::value_string( unsigned int field_index )
{
- static wchar_t initial_buffer[ 256 ] = L"" ;
- DWORD length = 255 ; // one less than the buffer length to hold a terminating null character
+ static wchar_t initial_buffer[ 1024 ] = L"" ;
+ DWORD length = 1023 ; // one less than the buffer length to hold a terminating null character
UINT x = MsiRecordGetStringW( _handle, field_index, initial_buffer, & length ) ;
if ( x == ERROR_SUCCESS )
{
@@ -61,9 +62,13 @@
if ( x == ERROR_MORE_DATA )
{
// Future: handle longer strings.
- throw std::runtime_error( "Record strings longer than 255 not supported yet" ) ;
+ /*
+ * The present custom action only uses this function for strings that appear in dialog boxes.
+ * A thousand characters is about a dozen lines of text, which is far more than enough.
+ */
+ throw not_yet_supported( "retrieving string values longer than 1023 from a record" ) ;
Oleksandr 2014/03/31 07:35:49 Still, why not just dynamically allocate the buffe
Eric 2014/03/31 11:23:09 It wouldn't. The main reason is that we have no ne
}
- throw std::runtime_error( "Error retrieving string from record" ) ;
+ throw windows_api_error( "MsiRecordGetStringW", x ) ;
}
size_t Record::n_fields() const
@@ -71,7 +76,7 @@
unsigned int x = MsiRecordGetFieldCount( _handle ) ;
if ( x == 0xFFFFFFFF )
{
- throw std::runtime_error( "Invalid handle" ) ;
+ throw windows_api_error( "MsiRecordGetFieldCount", x, "invalid handle" ) ;
}
return x ;
}
« no previous file with comments | « installer/src/installer-lib/property.cpp ('k') | installer/src/installer-lib/session.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld