lmi-commits
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]