Commit Graph

57 Commits

Author SHA1 Message Date
Ladislav Michl
c293d74566 Base: rename Exception's PascalCase methods to camelCase 2025-05-05 23:50:01 +02:00
bofdahof
838178bb1c Base: simplify Exception
Remove repetition. Add functions to replace macros, but keep macros
in use for now as some compilers have broken std::source_location
support.
2025-05-05 23:50:01 +02:00
marioalexis
776158addd Base: Add PropertyError exception 2024-08-02 20:19:16 -03:00
wmayer
c2694fd7d9 Base: cppcoreguidelines 2023-11-24 00:11:32 +01:00
wmayer
08b10cd287 fix cppcoreguidelines-*
* cppcoreguidelines-init-variables
* cppcoreguidelines-c-copy-assignment-signature
* cppcoreguidelines-macro-usage
* cppcoreguidelines-non-private-member-variables-in-classes
* cppcoreguidelines-pro-type-member-init
* cppcoreguidelines-slicing
* cppcoreguidelines-special-member-functions
* cppcoreguidelines-virtual-class-destructor
2023-11-16 01:22:09 +01:00
wmayer
f539138dd9 fix readability-*:
* readability-const-return-type
* readability-container-data-pointer
* readability-container-size-empty
* readability-delete-null-pointer
* readability-else-after-return
* readability-inconsistent-declaration-parameter-name
* readability-redundant-member-init
* readability-redundant-smartptr-get
* readability-redundant-string-cstr
* readability-use-anyofallof
* readability-static-definition-in-anonymous-namespace
* readability-static-accessed-through-instance
* readability-simplify-boolean-expr
2023-11-16 01:22:08 +01:00
wmayer
e4975f0153 fix readability-braces-around-statements 2023-11-16 01:22:08 +01:00
wmayer
e85c383bff Base: apply clang format 2023-11-13 12:01:26 -05:00
wmayer
010dca8303 Base: C++ core guidelines: init variables 2023-08-24 18:48:52 +02:00
wmayer
db0f6534c3 Base: modernize C++: use equals default 2023-08-20 18:10:17 +02:00
wmayer
c7a17468e7 modernize C++: use noexcept 2023-08-07 16:06:58 +02:00
Uwe
90abdf2752 [Base] remove some more superfluous nullptr checks 2022-07-18 13:07:16 +02:00
wmayer
9160f06e1c Base: rename BaseExceptionFreeCADError to PyExc_FC_GeneralError 2022-03-17 14:45:48 +01:00
wmayer
d69defaa3c Py: replace BaseExceptionFreeCADError with more suitable exception types 2022-03-17 13:54:23 +01:00
wmayer
10a13c6dbc Base: add more custom Python exception types 2022-03-17 11:29:09 +01:00
Uwe
a5c838fefc [Base] some sorting and cleanup 2022-03-02 01:51:05 +01:00
Uwe
89b37a5110 [Base] Exception and FileInfo: remove unused includes 2022-02-23 19:13:13 +01:00
wmayer
4d87039635 Base: modernize C++11
* remove redundant void-arg
* use nullptr
* replace deprecated headers
2022-01-25 20:21:30 +01:00
wmayer
31e2e95203 Base: Exception handling:
* Harmonize FreeCAD with Python exception types
* Implement AbortException::getPyExceptionType() to avoid handling it in client code
* Remove catch block for plain C strings
2022-01-19 18:00:04 +01:00
wmayer
dfe84ef123 Base: [skip ci] pass the full file path to the FileException 2021-09-29 14:02:46 +02:00
Heewa Barfchin
bf6dfb7572 Fix lost filename in err msg
In some circumstances, FileExceptions are constructed empty, then have a
filename assigned to them, but the error message in these scenarios is
left as the default "unknown" one, which is sometimes shown to users.
This change fixes that case to be consistent with instances that are
constructed with the filename.
2021-05-14 12:34:20 -04:00
luz paz
142c2c2c4d Base: remove Py2 code 2021-04-26 09:23:58 +02:00
luz paz
d5f6c096b8 Base: Fix header uniformity, whitespace, and doxygen
[skip ci]
2020-11-22 18:12:16 +01:00
wmayer
6199fbb25e Base: [skip ci] Coverity: Uncaught exception 2020-09-14 18:34:25 +02:00
wmayer
3b0eeb63e8 LGTM: [skip ci] fix: Inconsistent definition of copy constructor and assignment ('Rule of Two')
Remove user-defined copy constructor of Exception classes without assignment operator
2020-07-27 13:47:41 +02:00
wmayer
43d9e82f97 Coverity: Uncaught exception 2020-07-20 17:34:26 +02:00
luz.paz
d36c3ebe57 Trivial code formatting for some {.cpp,.h} files 2020-04-06 12:55:27 +02:00
wmayer
49bfbf73f8 Base: [skip ci] add method to more easily set the Python error indicator from a Base::Exception 2020-03-18 17:53:13 +01:00
luz.paz
6f11ed298a src/Base: [skip ci] fix header uniformity
This PR fixes header uniformity across all `src/Base` files
2019-12-25 11:38:58 +01:00
wmayer
b50b21576e core system
force strict ISO C++ (-Wpedantic)
TODO: still a lot of variadic macros are not valid ISO C++
2019-09-18 01:01:14 +02:00
Zheng, Lei
59417068f5 Base: improve exception
For better FC and Python exception mapping.
2019-08-17 14:52:08 +02:00
wmayer
7ceac311b3 add specialized exception type for bad graphs 2018-11-26 14:15:19 +01:00
wmayer
ddb20468ad some additions to pR 1794:
add a special XMLAttributeError class to indicate an error when accessing a missing attribute
in PropertyContainer::Restore make error handling more flexible
2018-11-19 19:07:56 +01:00
Abdullah Tahiri
a459ee3f22 New Base::Exception type RestoreError 2018-11-19 11:31:07 +01:00
wmayer
7a95962037 fixes of PR 765
remove QT_TRANSLATE_NOOP because of compiler warnings
mark _isReported as mutable to avoid removing const keyword from ReportException()
improve whitespaces
2017-08-17 22:50:01 +02:00
Abdullah Tahiri
572bd0ae01 Exception extension to only report once 2017-08-17 22:45:40 +02:00
Abdullah Tahiri
3c630dc319 Exceptions: translation support 2017-08-17 22:44:11 +02:00
wmayer
dc413acc42 fix build failure and make Py2/Py3 specific change 2017-05-15 22:36:21 +02:00
wmayer
7d47a723fb Fix various issues:
+ fix dangling pointers when fetching Python error text
+ initialize members in overloaded constructors of Exception class
+ implement assignment operator in sub-class
+ move to PyCXX API to simplify handling with reference counting and reading values from the dict
2017-05-15 18:49:09 +02:00
wmayer
4971818321 fix -Woverloaded-virtual 2017-05-13 16:46:49 +02:00
wmayer
017752b9d8 improve whitespaces and reduce code duplication 2017-05-13 16:00:32 +02:00
Abdullah Tahiri
a7bc962ce5 Renaming getPyDict to getPyObject for consistency with BaseClass 2017-05-13 15:27:57 +02:00
Abdullah Tahiri
b410f8857c Enable exceptions to save/restore information in a python dictionary and enable throwing exception from dictionary information 2017-05-13 15:27:57 +02:00
Abdullah Tahiri
57698ef73c Provide default constructors for all exception types 2017-05-13 15:27:57 +02:00
Abdullah Tahiri
d7fafbf5a6 Exception: Extension to access debug information and change of line to int type 2017-05-13 15:27:57 +02:00
Abdullah Tahiri
1091511c77 Base::Exception extension
=========================

1. Enable automatic storing of information (function, file, line) when throwing the exception via macro:

Examples:

THROWM(Exception, "BSpline GeoId is out of bounds.")
THROWM(ValueError, "BSpline GeoId is out of bounds.")

THROW(AbortException)

Output:

a) Python Console (what()):
App.ActiveDocument.Sketch004.modifyBSplineKnotMultiplicity(16,3,0)
Traceback (most recent call last):
File "<input>", line 1, in <module>
Base.FreeCADError: FreeCAD exception thrown (BSpline GeoId is out of bounds.)

b) ReportException (report()):
Exception (Thu Apr 27 19:15:24 2017): BSpline GeoId is out of bounds. in bool Sketcher::SketchObject::modifyBSplineKnotMultiplicity(int, int, int) in src/Mod/Sketcher/App/SketchObject.cpp:4102

2. Extend the basic framework so as to allow more control over the mangling of the message introduced by the user, setting the basis to allow, where needed,
 to preserve the original message while allowing full legacy behaviour.

3. Supporting FileDialog reporting as legacy
2017-05-03 22:08:10 +02:00
Abdullah Tahiri
c974e9d752 Exception: Add CADKernelError exception for specialized OCC exception propagation to App::DocumentObject 2017-05-03 22:08:10 +02:00
wmayer
1673ab801e use specialized exception classes 2017-04-28 18:49:11 +02:00
wmayer
f408f3180b fix -Wextra in FreeCADBase 2016-09-21 15:02:02 +02:00
wmayer
f8c0d2f05d + fix possible crash when throw file exception 2016-06-11 16:25:06 +02:00