summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-12 12:15:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-14 08:34:38 +0200
commitfd3888c69abd813462360f49f853fa988764596c (patch)
tree12ac0b3d2de79dbc53de874b209ef83bf5c31a21 /comphelper
parent5cc45f148dac2080d5cdc2d69db539d55b1ff816 (diff)
move ErrCode to comphelper and improve debug output string
need to move it, because modules "below" vcl want to use the debug output method Change-Id: Ibcaf4089a1e0b3fcc0b5189c7ebf1aae90f50b48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139791 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/Library_comphelper.mk1
-rw-r--r--comphelper/source/misc/errcode.cxx161
2 files changed, 162 insertions, 0 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk
index 4b601785b544..ffa06369ddbd 100644
--- a/comphelper/Library_comphelper.mk
+++ b/comphelper/Library_comphelper.mk
@@ -104,6 +104,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
comphelper/source/misc/docpasswordhelper \
comphelper/source/misc/docpasswordrequest \
comphelper/source/misc/documentinfo \
+ comphelper/source/misc/errcode \
comphelper/source/misc/evtlistenerhlp \
comphelper/source/misc/evtmethodhelper \
comphelper/source/misc/fileurl \
diff --git a/comphelper/source/misc/errcode.cxx b/comphelper/source/misc/errcode.cxx
new file mode 100644
index 000000000000..b8d8230d0a7a
--- /dev/null
+++ b/comphelper/source/misc/errcode.cxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/errcode.hxx>
+#include <rtl/ustrbuf.hxx>
+
+COMPHELPER_DLLPUBLIC OUString ErrCode::toString() const
+{
+ OUStringBuffer buf(128);
+ buf.append(toHexString() + "(");
+ if (IsWarning())
+ buf.append("Warning");
+ else
+ buf.append("Error");
+ if (IsDynamic())
+ buf.append(" Dynamic");
+ else
+ {
+ std::u16string_view pArea;
+ switch (GetArea())
+ {
+ case ErrCodeArea::Io:
+ pArea = u"Io";
+ break;
+ case ErrCodeArea::Sfx:
+ pArea = u"Sfx";
+ break;
+ case ErrCodeArea::Inet:
+ pArea = u"Inet";
+ break;
+ case ErrCodeArea::Vcl:
+ pArea = u"Vcl";
+ break;
+ case ErrCodeArea::Svx:
+ pArea = u"Svx";
+ break;
+ case ErrCodeArea::So:
+ pArea = u"So";
+ break;
+ case ErrCodeArea::Sbx:
+ pArea = u"Sbx";
+ break;
+ case ErrCodeArea::Uui:
+ pArea = u"Uui";
+ break;
+ case ErrCodeArea::Sc:
+ pArea = u"Sc";
+ break;
+ case ErrCodeArea::Sd:
+ pArea = u"Sd";
+ break;
+ case ErrCodeArea::Sw:
+ pArea = u"Sw";
+ break;
+ }
+ buf.append(OUString::Concat(" Area:") + pArea);
+
+ std::u16string_view pClass;
+ switch (GetClass())
+ {
+ case ErrCodeClass::NONE:
+ pClass = u"NONE";
+ break;
+ case ErrCodeClass::Abort:
+ pClass = u"Abort";
+ break;
+ case ErrCodeClass::General:
+ pClass = u"General";
+ break;
+ case ErrCodeClass::NotExists:
+ pClass = u"NotExists";
+ break;
+ case ErrCodeClass::AlreadyExists:
+ pClass = u"AlreadyExists";
+ break;
+ case ErrCodeClass::Access:
+ pClass = u"Access";
+ break;
+ case ErrCodeClass::Path:
+ pClass = u"Path";
+ break;
+ case ErrCodeClass::Locking:
+ pClass = u"Locking";
+ break;
+ case ErrCodeClass::Parameter:
+ pClass = u"Parameter";
+ break;
+ case ErrCodeClass::Space:
+ pClass = u"Space";
+ break;
+ case ErrCodeClass::NotSupported:
+ pClass = u"NotSupported";
+ break;
+ case ErrCodeClass::Read:
+ pClass = u"Read";
+ break;
+ case ErrCodeClass::Write:
+ pClass = u"Write";
+ break;
+ case ErrCodeClass::Unknown:
+ pClass = u"Unknown";
+ break;
+ case ErrCodeClass::Version:
+ pClass = u"Version";
+ break;
+ case ErrCodeClass::Format:
+ pClass = u"Format";
+ break;
+ case ErrCodeClass::Create:
+ pClass = u"Create";
+ break;
+ case ErrCodeClass::Import:
+ pClass = u"Import";
+ break;
+ case ErrCodeClass::Export:
+ pClass = u"Export";
+ break;
+ case ErrCodeClass::So:
+ pClass = u"So";
+ break;
+ case ErrCodeClass::Sbx:
+ pClass = u"Sbx";
+ break;
+ case ErrCodeClass::Runtime:
+ pClass = u"Runtime";
+ break;
+ case ErrCodeClass::Compiler:
+ pClass = u"Compiler";
+ break;
+ }
+ buf.append(OUString::Concat(" Class:") + pClass);
+
+ buf.append(" Code:" + OUString::number(GetCode()));
+ }
+ buf.append(")");
+ return buf.makeStringAndClear();
+}
+
+COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
+{
+ os << err.toString();
+ return os;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */