Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / comphelper / source / misc / errcode.cxx
blob77d58ac364be9f3bed5f521f4de85ed8caf7bfe1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <comphelper/errcode.hxx>
21 #include <rtl/ustrbuf.hxx>
23 COMPHELPER_DLLPUBLIC OUString ErrCode::toString() const
25 OUStringBuffer buf(128);
26 buf.append(toHexString() + "(");
27 if (IsWarning())
28 buf.append("Warning");
29 else
30 buf.append("Error");
31 if (IsDynamic())
32 buf.append(" Dynamic");
33 else
35 std::u16string_view pArea;
36 switch (GetArea())
38 case ErrCodeArea::Io:
39 pArea = u"Io";
40 break;
41 case ErrCodeArea::Sfx:
42 pArea = u"Sfx";
43 break;
44 case ErrCodeArea::Inet:
45 pArea = u"Inet";
46 break;
47 case ErrCodeArea::Vcl:
48 pArea = u"Vcl";
49 break;
50 case ErrCodeArea::Svx:
51 pArea = u"Svx";
52 break;
53 case ErrCodeArea::So:
54 pArea = u"So";
55 break;
56 case ErrCodeArea::Sbx:
57 pArea = u"Sbx";
58 break;
59 case ErrCodeArea::Uui:
60 pArea = u"Uui";
61 break;
62 case ErrCodeArea::Sc:
63 pArea = u"Sc";
64 break;
65 case ErrCodeArea::Sd:
66 pArea = u"Sd";
67 break;
68 case ErrCodeArea::Sw:
69 pArea = u"Sw";
70 break;
72 buf.append(OUString::Concat(" Area:") + pArea);
74 std::u16string_view pClass;
75 switch (GetClass())
77 case ErrCodeClass::NONE:
78 pClass = u"NONE";
79 break;
80 case ErrCodeClass::Abort:
81 pClass = u"Abort";
82 break;
83 case ErrCodeClass::General:
84 pClass = u"General";
85 break;
86 case ErrCodeClass::NotExists:
87 pClass = u"NotExists";
88 break;
89 case ErrCodeClass::AlreadyExists:
90 pClass = u"AlreadyExists";
91 break;
92 case ErrCodeClass::Access:
93 pClass = u"Access";
94 break;
95 case ErrCodeClass::Path:
96 pClass = u"Path";
97 break;
98 case ErrCodeClass::Locking:
99 pClass = u"Locking";
100 break;
101 case ErrCodeClass::Parameter:
102 pClass = u"Parameter";
103 break;
104 case ErrCodeClass::Space:
105 pClass = u"Space";
106 break;
107 case ErrCodeClass::NotSupported:
108 pClass = u"NotSupported";
109 break;
110 case ErrCodeClass::Read:
111 pClass = u"Read";
112 break;
113 case ErrCodeClass::Write:
114 pClass = u"Write";
115 break;
116 case ErrCodeClass::Unknown:
117 pClass = u"Unknown";
118 break;
119 case ErrCodeClass::Version:
120 pClass = u"Version";
121 break;
122 case ErrCodeClass::Format:
123 pClass = u"Format";
124 break;
125 case ErrCodeClass::Create:
126 pClass = u"Create";
127 break;
128 case ErrCodeClass::Import:
129 pClass = u"Import";
130 break;
131 case ErrCodeClass::Export:
132 pClass = u"Export";
133 break;
134 case ErrCodeClass::So:
135 pClass = u"So";
136 break;
137 case ErrCodeClass::Sbx:
138 pClass = u"Sbx";
139 break;
140 case ErrCodeClass::Runtime:
141 pClass = u"Runtime";
142 break;
143 case ErrCodeClass::Compiler:
144 pClass = u"Compiler";
145 break;
147 buf.append(OUString::Concat(" Class:") + pClass + " Code:" + OUString::number(GetCode()));
149 buf.append(")");
150 return buf.makeStringAndClear();
153 COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
155 os << err.toString();
156 return os;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */