Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • util
pencilerror.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#ifndef PENCILERROR_H
19#define PENCILERROR_H
20
21#include <QCoreApplication>
22#include <QStringList>
23
24class DebugDetails
25{
26public:
27 DebugDetails();
28
29 void collect(const DebugDetails& d);
30 QString str();
31 QString html();
32 DebugDetails& operator<<(const QString& s);
33
34private:
35 void appendSystemInfo();
36 QStringList mDetails;
37};
38
39class Status
40{
41 Q_DECLARE_TR_FUNCTIONS(Status)
42public:
43 enum ErrorCode
44 {
45 OK = 0,
46 SAFE,
47 FAIL,
48 CANCELED,
49 FILE_NOT_FOUND,
50 NOT_SUPPORTED,
51 INVALID_ARGUMENT,
52 NOT_IMPLEMENTED_YET,
53
54 // for Object load/save
55 ERROR_FILE_CANNOT_OPEN,
56 ERROR_INVALID_XML_FILE,
57 ERROR_INVALID_PENCIL_FILE,
58 ERROR_MINIZ_FAIL,
59
60 // General
61 ERROR_INVALID_LAYER_TYPE,
62 ERROR_INVALID_FRAME_NUMBER,
63 ERROR_LOAD_IMAGE_FAIL,
64
65 // Sound
66 ERROR_LOAD_SOUND_FILE,
67
68 // Export
69 ERROR_FFMPEG_NOT_FOUND,
70
71 // Layer
72 ERROR_NEED_AT_LEAST_ONE_CAMERA_LAYER
73 };
74
75 Status(const ErrorCode code);
76 Status(const ErrorCode code, const QString& description);
77 Status(const ErrorCode code, const DebugDetails& detailsList);
78 Status(const ErrorCode code, const DebugDetails& detailsList, QString title, QString description);
79
80 ErrorCode code() const { return mCode; }
81 bool ok() const { return (mCode == OK) || (mCode == SAFE); }
82 QString msg() const;
83 QString title() const { return !mTitle.isEmpty() ? mTitle : msg(); }
84 QString description() const { return mDescription; }
85 DebugDetails details() const { return mDetails; }
86
87 void setTitle(QString title) { mTitle = title; }
88 void setDescription(QString description) { mDescription = description; }
89 void setDetails(DebugDetails dd) { mDetails = dd; }
90
91 bool operator==(ErrorCode code) const;
92 bool operator!=(ErrorCode code) const;
93
94private:
95 ErrorCode mCode = OK;
96 QString mTitle;
97 QString mDescription;
98 DebugDetails mDetails;
99};
100
101#ifndef STATUS_CHECK
102#define STATUS_CHECK( x )\
103 { Status st = (x); if (!st.ok()) { return st; } }
104#endif
105
106#ifndef STATUS_FAILED
107#define STATUS_FAILED(stcode) ((int)stcode >= (int)Status::FAIL)
108#endif
109
110#endif // PENCILERROR_H
DebugDetails
Definition: pencilerror.h:25
Status
Definition: pencilerror.h:40
QString
QString::isEmpty
bool isEmpty() const const
QStringList
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39