Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F20320946
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
2 KB
Subscribers
None
View Options
diff --git a/exception.cpp b/exception.cpp
index bb413c5d..bcee7e1f 100644
--- a/exception.cpp
+++ b/exception.cpp
@@ -1,55 +1,47 @@
/*
exception.cpp - exception wrapping a gpgme error
Copyright (C) 2007 Klarälvdalens Datakonsult AB
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
GPGME++ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#include "exception.h"
#include <gpg-error.h>
-#include <cstdio>
+#include <sstream>
using namespace GpgME;
using namespace std; // only safe b/c it's so small a file!
Exception::~Exception() throw() {}
// static
string Exception::make_message( const Error & err, const string & msg ) {
- char buf[128];
- buf[0] = '\0';
- gpg_strerror_r( err, buf, sizeof buf );
- buf[sizeof buf - 1] = '\0';
- char result_buf[256];
- int numChars = 0;
- if ( msg.empty() )
- numChars = snprintf( result_buf, sizeof result_buf, "%lu %s: %s",
- static_cast<unsigned long>(err), gpg_strsource( err ), buf );
- else
- numChars = snprintf( result_buf, sizeof result_buf, "%lu %s: %s - %s",
- static_cast<unsigned long>(err), gpg_strsource( err ), buf, msg.c_str() );
- result_buf[sizeof result_buf - 1] = '\0';
- if ( numChars < 0 )
- numChars = 0; // error - truncate string
- if ( numChars > static_cast<int>(sizeof result_buf) )
- numChars = sizeof result_buf;
- return string( result_buf, numChars );
+ char error_string[128];
+ error_string[0] = '\0';
+ gpg_strerror_r( err, error_string, sizeof error_string );
+ error_string[sizeof error_string - 1] = '\0';
+ stringstream ss;
+ ss << gpg_strsource( err ) << ": ";
+ if ( !msg.empty() )
+ ss << msg << ": ";
+ ss << error_string << " (" << static_cast<unsigned long>( err ) << ')';
+ return ss.str();
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Mar 14, 4:52 AM (4 m, 41 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
74/1b/bc9494844623a563648e680a4bd1
Attached To
rGPGMEPP Gpgme plus plus
Event Timeline
Log In to Comment