Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/comphelper/source/misc/errcode.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <comphelper/errcode.hxx>
21
#include <o3tl/runtimetooustring.hxx>
22
23
UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OUString ErrCode::toString() const
24
0
{
25
0
    std::u16string_view pWarningError;
26
0
    if (IsWarning())
27
0
        pWarningError = u"Warning";
28
0
    else
29
0
        pWarningError = u"Error";
30
31
0
    std::u16string_view pArea;
32
0
    switch (GetArea())
33
0
    {
34
0
        case ErrCodeArea::Io:
35
0
            pArea = u"Io";
36
0
            break;
37
0
        case ErrCodeArea::Sfx:
38
0
            pArea = u"Sfx";
39
0
            break;
40
0
        case ErrCodeArea::Inet:
41
0
            pArea = u"Inet";
42
0
            break;
43
0
        case ErrCodeArea::Vcl:
44
0
            pArea = u"Vcl";
45
0
            break;
46
0
        case ErrCodeArea::Svx:
47
0
            pArea = u"Svx";
48
0
            break;
49
0
        case ErrCodeArea::So:
50
0
            pArea = u"So";
51
0
            break;
52
0
        case ErrCodeArea::Sbx:
53
0
            pArea = u"Sbx";
54
0
            break;
55
0
        case ErrCodeArea::Uui:
56
0
            pArea = u"Uui";
57
0
            break;
58
0
        case ErrCodeArea::Sc:
59
0
            pArea = u"Sc";
60
0
            break;
61
0
        case ErrCodeArea::Sd:
62
0
            pArea = u"Sd";
63
0
            break;
64
0
        case ErrCodeArea::Sw:
65
0
            pArea = u"Sw";
66
0
            break;
67
0
    }
68
69
0
    std::u16string_view pClass;
70
0
    switch (GetClass())
71
0
    {
72
0
        case ErrCodeClass::NONE:
73
0
            pClass = u"NONE";
74
0
            break;
75
0
        case ErrCodeClass::Abort:
76
0
            pClass = u"Abort";
77
0
            break;
78
0
        case ErrCodeClass::General:
79
0
            pClass = u"General";
80
0
            break;
81
0
        case ErrCodeClass::NotExists:
82
0
            pClass = u"NotExists";
83
0
            break;
84
0
        case ErrCodeClass::AlreadyExists:
85
0
            pClass = u"AlreadyExists";
86
0
            break;
87
0
        case ErrCodeClass::Access:
88
0
            pClass = u"Access";
89
0
            break;
90
0
        case ErrCodeClass::Path:
91
0
            pClass = u"Path";
92
0
            break;
93
0
        case ErrCodeClass::Locking:
94
0
            pClass = u"Locking";
95
0
            break;
96
0
        case ErrCodeClass::Parameter:
97
0
            pClass = u"Parameter";
98
0
            break;
99
0
        case ErrCodeClass::Space:
100
0
            pClass = u"Space";
101
0
            break;
102
0
        case ErrCodeClass::NotSupported:
103
0
            pClass = u"NotSupported";
104
0
            break;
105
0
        case ErrCodeClass::Read:
106
0
            pClass = u"Read";
107
0
            break;
108
0
        case ErrCodeClass::Write:
109
0
            pClass = u"Write";
110
0
            break;
111
0
        case ErrCodeClass::Unknown:
112
0
            pClass = u"Unknown";
113
0
            break;
114
0
        case ErrCodeClass::Version:
115
0
            pClass = u"Version";
116
0
            break;
117
0
        case ErrCodeClass::Format:
118
0
            pClass = u"Format";
119
0
            break;
120
0
        case ErrCodeClass::Create:
121
0
            pClass = u"Create";
122
0
            break;
123
0
        case ErrCodeClass::Import:
124
0
            pClass = u"Import";
125
0
            break;
126
0
        case ErrCodeClass::Export:
127
0
            pClass = u"Export";
128
0
            break;
129
0
        case ErrCodeClass::So:
130
0
            pClass = u"So";
131
0
            break;
132
0
        case ErrCodeClass::Sbx:
133
0
            pClass = u"Sbx";
134
0
            break;
135
0
        case ErrCodeClass::Runtime:
136
0
            pClass = u"Runtime";
137
0
            break;
138
0
        case ErrCodeClass::Compiler:
139
0
            pClass = u"Compiler";
140
0
            break;
141
0
    }
142
0
    return toHexString() + "(" + pWarningError + " Area:" + pArea + " Class:" + pClass
143
0
           + " Code:" + OUString::number(GetCode()) + ")";
144
0
}
145
146
COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
147
0
{
148
0
    os << err.toString();
149
0
    return os;
150
0
}
151
152
UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OUString ErrCodeMsg::toString() const
153
0
{
154
0
    OUString s = mnCode.toString();
155
0
    if (!maArg1.isEmpty())
156
0
        s += " arg1=" + maArg1;
157
0
    if (!maArg2.isEmpty())
158
0
        s += " arg2=" + maArg2;
159
#ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
160
    if (!moLoc)
161
        s += OUString::Concat(" func=") + o3tl::runtimeToOUString(moLoc->function_name()) + " src="
162
             + o3tl::runtimeToOUString(moLoc->file_name()) + ":" + OUString::number(moLoc->line());
163
#endif
164
0
    return s;
165
0
}
166
167
COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCodeMsg& err)
168
0
{
169
0
    os << err.toString();
170
0
    return os;
171
0
}
172
173
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */