[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master ecd1362 3/9: Shorten diagnostics
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master ecd1362 3/9: Shorten diagnostics |
Date: |
Wed, 4 Apr 2018 21:27:37 -0400 (EDT) |
branch: master
commit ecd1362df9f779cd9684f14aea6e40546b9bb351
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Shorten diagnostics
The benefit of elaborate assertions is that they specifically indicate
what has gone wrong. The cost is that they make the code longer and
harder to read, and that they must be maintained if the variables and
functions they use ever change. It's a tradeoff, and a matter of taste,
but in this case simplicity seems preferable.
---
pdf_writer_wx.cpp | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index b2f05d2..e25408f 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -127,13 +127,7 @@ pdf_writer_wx::pdf_writer_wx
wxDC& pdf_writer_wx::dc()
{
- LMI_ASSERT_WITH_MSG
- (!save_has_been_called_
- ,"Can't use device context of the PDF file \""
- << print_data_.GetFilename().ToStdString(wxConvUTF8)
- << "\" which was already saved"
- );
-
+ LMI_ASSERT(!save_has_been_called_);
return pdf_dc_;
}
@@ -154,12 +148,7 @@ void pdf_writer_wx::output_image
,oenum_render_or_only_measure output_mode
)
{
- LMI_ASSERT_WITH_MSG
- (!save_has_been_called_
- ,"Can't add an image to the PDF file \""
- << print_data_.GetFilename().ToStdString(wxConvUTF8)
- << "\" which was already saved"
- );
+ LMI_ASSERT(!save_has_been_called_);
int const y = wxRound(image.GetHeight() / scale);
@@ -199,12 +188,7 @@ int pdf_writer_wx::output_html
,oenum_render_or_only_measure output_mode
)
{
- LMI_ASSERT_WITH_MSG
- (!save_has_been_called_
- ,"Can't output HTML to the PDF file \""
- << print_data_.GetFilename().ToStdString(wxConvUTF8)
- << "\" which was already saved"
- );
+ LMI_ASSERT(!save_has_been_called_);
// We don't really want to change the font, but to preserve the current DC
// font which is changed by rendering the HTML contents.
- [lmi-commits] [lmi] master updated (d9f9215 -> f4580cf), Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master 035e5a0 2/9: Simplify, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master afdbbeb 6/9: Consolidate commentary, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master 38df10a 4/9: Simplify diagnostics, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master 6586cab 1/9: Simplify, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master ecd1362 3/9: Shorten diagnostics,
Greg Chicares <=
- [lmi-commits] [lmi] master 783f4dd 5/9: Consolidate and revise documentation, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master f4580cf 9/9: Don't ref-qualify save(), Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master 5d225f5 7/9: Move commentary to point of member-function definition, Greg Chicares, 2018/04/04
- [lmi-commits] [lmi] master f5651d1 8/9: Prevent save() from being called twice, Greg Chicares, 2018/04/04