1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
22 #include <o3tl/runtimetooustring.hxx>
24 UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC
) OUString
ErrCode::toString() const
26 std::u16string_view pWarningError
;
28 pWarningError
= u
"Warning";
30 pWarningError
= u
"Error";
32 std::u16string_view pArea
;
38 case ErrCodeArea::Sfx
:
41 case ErrCodeArea::Inet
:
44 case ErrCodeArea::Vcl
:
47 case ErrCodeArea::Svx
:
53 case ErrCodeArea::Sbx
:
56 case ErrCodeArea::Uui
:
70 std::u16string_view pClass
;
73 case ErrCodeClass::NONE
:
76 case ErrCodeClass::Abort
:
79 case ErrCodeClass::General
:
82 case ErrCodeClass::NotExists
:
83 pClass
= u
"NotExists";
85 case ErrCodeClass::AlreadyExists
:
86 pClass
= u
"AlreadyExists";
88 case ErrCodeClass::Access
:
91 case ErrCodeClass::Path
:
94 case ErrCodeClass::Locking
:
97 case ErrCodeClass::Parameter
:
98 pClass
= u
"Parameter";
100 case ErrCodeClass::Space
:
103 case ErrCodeClass::NotSupported
:
104 pClass
= u
"NotSupported";
106 case ErrCodeClass::Read
:
109 case ErrCodeClass::Write
:
112 case ErrCodeClass::Unknown
:
115 case ErrCodeClass::Version
:
118 case ErrCodeClass::Format
:
121 case ErrCodeClass::Create
:
124 case ErrCodeClass::Import
:
127 case ErrCodeClass::Export
:
130 case ErrCodeClass::So
:
133 case ErrCodeClass::Sbx
:
136 case ErrCodeClass::Runtime
:
139 case ErrCodeClass::Compiler
:
140 pClass
= u
"Compiler";
143 return toHexString() + "(" + pWarningError
+ " Area:" + pArea
+ " Class:" + pClass
144 + " Code:" + OUString::number(GetCode()) + ")";
147 COMPHELPER_DLLPUBLIC
std::ostream
& operator<<(std::ostream
& os
, const ErrCode
& err
)
149 os
<< err
.toString();
153 UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC
) OUString
ErrCodeMsg::toString() const
155 OUString s
= mnCode
.toString();
156 if (!maArg1
.isEmpty())
157 s
+= " arg1=" + maArg1
;
158 if (!maArg2
.isEmpty())
159 s
+= " arg2=" + maArg2
;
160 #ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
162 s
+= OUString::Concat(" func=") + o3tl::runtimeToOUString(moLoc
->function_name()) + " src="
163 + o3tl::runtimeToOUString(moLoc
->file_name()) + ":" + OUString::number(moLoc
->line());
168 COMPHELPER_DLLPUBLIC
std::ostream
& operator<<(std::ostream
& os
, const ErrCodeMsg
& err
)
170 os
<< err
.toString();
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */