KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_git_errors.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_GIT_ERRORS_H
21#define KICAD_GIT_ERRORS_H
22
23#include <vector>
24#include <import_export.h>
25
26#include <wx/translation.h>
27
28
31{
32 wxString summary;
33 wxString details;
34};
35
36
38{
39public:
40
41 KIGIT_ERRORS() = default;
42 virtual ~KIGIT_ERRORS() = default;
43
44 const std::vector<wxString>& GetErrorStrings() const
45 {
46 return m_errorStrings;
47 }
48
49 wxString GetErrorString()
50 {
51 if( m_errorStrings.empty() )
52 return _( "No error" );
53
54 const wxString errorString( m_errorStrings.back() );
55 m_errorStrings.pop_back();
56 m_errorDetails.pop_back();
57 return errorString;
58 }
59
62 {
63 if( m_errorStrings.empty() )
64 return {};
65
67 m_errorStrings.pop_back();
68 m_errorDetails.pop_back();
69 return message;
70 }
71
74 void AddError( const wxString& aSummary, const wxString& aDetails );
75
76 void AddError( const KIGIT_ERROR_MESSAGE& aMessage ) { AddError( aMessage.summary, aMessage.details ); }
77
79 void AddGitError( const wxString& aSummary );
80
81 void AddErrorString( const wxString aErrorString )
82 {
83 AddError( aErrorString, wxEmptyString );
84 }
85
86 void AddErrorString( const std::string aErrorString )
87 {
88 AddError( wxString( aErrorString ), wxEmptyString );
89 }
90
91private:
92
93 std::vector<wxString> m_errorStrings;
94 std::vector<wxString> m_errorDetails;
95
96};
97
98#endif // KICAD_GIT_ERRORS_H
virtual ~KIGIT_ERRORS()=default
const std::vector< wxString > & GetErrorStrings() const
void AddErrorString(const wxString aErrorString)
KIGIT_ERROR_MESSAGE PopError()
Take the newest error with its details. Both are empty when none is queued.
void AddError(const wxString &aSummary, const wxString &aDetails)
A summary the user can act on, with the raw text that explains it kept apart for the details.
wxString GetErrorString()
void AddError(const KIGIT_ERROR_MESSAGE &aMessage)
std::vector< wxString > m_errorDetails
One per entry in m_errorStrings.
KIGIT_ERRORS()=default
void AddErrorString(const std::string aErrorString)
std::vector< wxString > m_errorStrings
#define _(s)
std::string message
#define APIEXPORT
Macros which export functions from a DLL/DSO.
A summary the user can act on, with the raw text that explains it kept apart for the details.