From c27f5b725dd2678b738621c52bcbe307a399b6a7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 21 Jul 2017 00:06:41 +1000 Subject: [PATCH] Improved various error messages - Moved developer "jargon" to details pane - Changed error messages to "WHAT" rather than "WHY" or "WHERE" --- common/confirm.cpp | 1 + common/gal/opengl/utils.cpp | 5 ++++- common/project.cpp | 4 ++-- cvpcb/cvpcb.cpp | 10 ++++------ eeschema/eeschema.cpp | 11 +++++------ include/confirm.h | 2 +- pcbnew/append_board_to_current.cpp | 8 +++----- pcbnew/basepcbframe.cpp | 4 +++- pcbnew/files.cpp | 8 +++----- pcbnew/onleftclick.cpp | 6 +++++- pcbnew/pcbnew.cpp | 12 ++++++------ pcbnew/pcbnew_config.cpp | 6 +++++- pcbnew/specctra_export.cpp | 6 +++--- pcbnew/specctra_import.cpp | 19 ++++++++++++------- pcbnew/tool_onrightclick.cpp | 4 +++- pcbnew/tool_pcb.cpp | 5 +++-- pcbnew/zones_by_polygon.cpp | 14 +++++++------- 17 files changed, 70 insertions(+), 55 deletions(-) diff --git a/common/confirm.cpp b/common/confirm.cpp index d8711b4a97..9c3ab3dfed 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -67,6 +67,7 @@ int DisplayExitDialog( wxWindow* parent, const wxString& aMessage ) } +// DisplayError should be deprecated, use DisplayErrorMessage instead void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) { wxMessageDialog* dialog; diff --git a/common/gal/opengl/utils.cpp b/common/gal/opengl/utils.cpp index 55366c7d0f..ad32d1d9b1 100644 --- a/common/gal/opengl/utils.cpp +++ b/common/gal/opengl/utils.cpp @@ -76,7 +76,10 @@ int checkGlError( const std::string& aInfo, bool aThrow ) if( aThrow ) throw std::runtime_error( (const char*) errorMsg.char_str() ); else - DisplayError( nullptr, errorMsg ); + DisplayErrorMessage( + nullptr, + _( "OpenGL error occurred" ), + errorMsg ); } return result; diff --git a/common/project.cpp b/common/project.cpp index 12e36473e7..4b481cc203 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -248,7 +248,7 @@ static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString "Unable to find '%s' template config file." ), GetChars( templateFile ) ); - DisplayError( NULL, msg ); + DisplayErrorMessage( nullptr, _( "Error copying project file template" ), msg ); return false; } @@ -412,7 +412,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway ) } catch( const IO_ERROR& ioe ) { - DisplayError( NULL, ioe.What() ); + DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ), ioe.What() ); } } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index c7a98aa034..5d65456b81 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -177,12 +177,10 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( - "An error occurred attempting to load the global footprint library " - "table:\n\n%s" ), - GetChars( ioe.What() ) - ); - DisplayError( NULL, msg ); + DisplayErrorMessage( + nullptr, + _( "An error occurred attempting to load the global footprint library table" ), + ioe.What() ); return false; } diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index bb4209642c..768deb21d6 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -267,13 +267,12 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) // if we are here, a incorrect global symbol library table was found. // Incorrect global symbol library table is not a fatal error: // the user just has to edit the (partially) loaded table. - wxString msg = wxString::Format( _( - "An error occurred attempting to load the global symbol library table:" - "\n\n%s\n\n" - "Please edit this global symbol library table in Preferences menu" ), - GetChars( ioe.What() ) + wxString msg = _( + "An error occurred attempting to load the global symbol library table.\n" + "Please edit this global symbol library table in Preferences menu" ); - DisplayError( NULL, msg ); + + DisplayErrorMessage( NULL, msg, ioe.What() ); } return true; diff --git a/include/confirm.h b/include/confirm.h index 9d8822d5b3..6dab366cf6 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/pcbnew/append_board_to_current.cpp b/pcbnew/append_board_to_current.cpp index 8c52f67f45..60b4aee0ff 100644 --- a/pcbnew/append_board_to_current.cpp +++ b/pcbnew/append_board_to_current.cpp @@ -86,13 +86,11 @@ bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl ) catch( const IO_ERROR& ioe ) { for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) + { track->ClearFlags( FLAG0 ); + } - wxString msg = wxString::Format( _( - "Error loading board.\n%s" ), - GetChars( ioe.What() ) - ); - DisplayError( this, msg ); + DisplayErrorMessage( this, _( "Error loading board in AppendBoardFile" ), ioe.What() ); return false; } diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 2e7de03b72..ba16929b76 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -160,7 +160,9 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs() } catch( const IO_ERROR& ioe ) { - DisplayError( NULL, ioe.What() ); + DisplayErrorMessage( nullptr, + _( "Error loading project footprint libraries" ), + ioe.What() ); } } diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 229e3adfa6..a88dc56a11 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -520,11 +520,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( - "Error loading board.\n%s" ), - GetChars( ioe.What() ) - ); - DisplayError( this, msg ); + DisplayErrorMessage( this, + wxString::Format( _( "Error loading board file:\n%s" ), fullFileName ), + ioe.What() ); return false; } diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 0da628708b..0144cadcd4 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -544,7 +544,11 @@ void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) if( curr_item->Type() != PCB_LINE_T ) { - DisplayError( this, wxT( "curr_item Type error" ) ); + DisplayErrorMessage( + this, + _( "Item type is incorrect" ), + wxString::Format( _( "Selected item type is %d\n" + "Expected: %d" ), curr_item->Type(), PCB_LINE_T ) ); m_canvas->SetAutoPanRequest( false ); break; } diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 84b6edd229..255aa37935 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -357,13 +357,13 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) // if we are here, a incorrect global footprint library table was found. // Incorrect global footprint library table is not a fatal error: // the user just has to edit the (partially) loaded table. - wxString msg = wxString::Format( _( - "An error occurred attempting to load the global footprint library " - "table:\n\n%s\n\n" - "Please edit this global footprint library table in Preferences menu" ), - GetChars( ioe.What() ) + + wxString msg = _( + "An error occurred attempting to load the global footprint library table:\n" + "Please edit this global footprint library table in Preferences menu" ); - DisplayError( NULL, msg ); + + DisplayErrorMessage( NULL, msg, ioe.What() ); } #if defined(KICAD_SCRIPTING) diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index ee9dda9929..dd4a245ba8 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -256,7 +256,11 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) break; default: - DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); + DisplayErrorMessage( + this, + _( "Unkown ID in Process Config" ), + wxString::Format( _( "PCB_EDIT_FRAME::Process_Config received ID %d" ), id ) ); + break; } } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 0618598f47..8eead1c6c5 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -151,9 +151,9 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename ) } else { - errorText += '\n'; - errorText += _( "Unable to export, please fix and try again." ); - DisplayError( this, errorText ); + DisplayErrorMessage( this, + _( "Unable to export, please fix and try again" ), + errorText ); } return ok; diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index fd00effe78..135035d8a6 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -85,9 +85,11 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) false ); if( fullFileName == wxEmptyString ) + { return; + } - SetCurItem( NULL ); + SetCurItem( NULL ); // To avoid issues with undo/redo lists (dangling pointers) // clear the lists @@ -104,13 +106,14 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) } catch( const IO_ERROR& ioe ) { - wxString msg = ioe.What(); - msg += '\n'; - msg += _("BOARD may be corrupted, do not save it."); - msg += '\n'; - msg += _("Fix problem and try again."); + wxString msg = _( + "Board may be corrupted, do not save it.\n" + "Fix problem and try again" + ); - DisplayError( this, msg ); + wxString extra = ioe.What(); + + DisplayErrorMessage( this, msg, extra); return; } @@ -129,7 +132,9 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) // add imported tracks (previous tracks are removed, therfore all are new) for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) + { view->Add( track ); + } } SetStatusText( wxString( _( "Session file imported and merged OK." ) ) ); diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp index c397575417..81095ff80c 100644 --- a/pcbnew/tool_onrightclick.cpp +++ b/pcbnew/tool_onrightclick.cpp @@ -101,7 +101,9 @@ void FOOTPRINT_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event ) break; default: - DisplayError( this, wxT( "ToolOnRightClick() error" ) ); + DisplayErrorMessage( this, + _( "Invalid tool ID "), + wxString::Format( _( "ToolOnRightClick called with ID %d" ), id ) ); break; } } diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 6f7fa766c3..6aa12e8aa5 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -813,8 +813,9 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) break; default: - DisplayError( this, - wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) ); + DisplayErrorMessage( this, + _( "Invalid toolbar option" ), + _( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) ); break; } } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 39c3bb9dcd..a26829676d 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -129,7 +129,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone ) // do nothing if( success && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) ) { - DisplayError( this, + DisplayErrorMessage( this, _( "The duplicated zone cannot be on the same layer as the original zone." ) ); success = false; } @@ -360,7 +360,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* if( error_count ) { - DisplayError( this, _( "Area: DRC outline error" ) ); + DisplayErrorMessage( this, _( "Area: DRC outline error" ) ); } } @@ -418,7 +418,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone ) if( error_count ) { - DisplayError( this, _( "Area: DRC outline error" ) ); + DisplayErrorMessage( this, _( "Area: DRC outline error" ) ); } } @@ -532,7 +532,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) { if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT && !IsCopperLayer( GetActiveLayer() ) ) { - DisplayError( this, + DisplayErrorMessage( this, _( "Error: a keepout area is allowed only on copper layers" ) ); return 0; } @@ -682,7 +682,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) // SCREEN::SetCurItem(), so the DRC error remains on screen. // PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo(). GetScreen()->SetCurItem( NULL ); - DisplayError( this, + DisplayErrorMessage( this, _( "DRC error: this start point is inside or too close an other area" ) ); return 0; } @@ -747,7 +747,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) if( g_Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge { - DisplayError( this, + DisplayErrorMessage( this, _( "DRC error: closing this area creates a DRC error with an other area" ) ); m_canvas->MoveCursorToCrossHair(); return false; @@ -809,7 +809,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) if( error_count ) { - DisplayError( this, _( "Area: DRC outline error" ) ); + DisplayErrorMessage( this, _( "Area: DRC outline error" ) ); } UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );