szaszm commented on code in PR #1335:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1335#discussion_r886739033


##########
libminifi/include/utils/Cron.h:
##########
@@ -0,0 +1,55 @@
+/**
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <exception>
+#include <string>
+#include <chrono>
+#include <optional>
+#include <memory>
+#include <utility>
+#include "date/tz.h"
+
+namespace org::apache::nifi::minifi::utils {
+class BadCronExpression : public std::exception {
+ public:
+  explicit BadCronExpression(std::string msg) : msg_(std::move(msg)) {}
+
+  [[nodiscard]] const char* what() const noexcept override { return 
(msg_.c_str()); }
+
+ private:
+  std::string msg_;

Review Comment:
   Avoid allocation in exception types. Instead use a base class that already 
provides a message buffer, and let it handle the message string, like we do in 
`minifi::Exception`. (Consider using that as your base class.)
   
   I couldn't find the reference, but basically exceptions have to copy the 
message to a special internal buffer anyway, because they need to be nothrow 
copyable.
   
   edit: found some references:
   https://clang.llvm.org/extra/clang-tidy/checks/cert-err60-cpp.html
   https://github.com/nlohmann/json/issues/531
   
https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR60-CPP.+Exception+objects+must+be+nothrow+copy+constructible
 (this one didn't load for me, but I think it might come back online eventually)
   
https://www.securecoding.cert.org/confluence/display/cplusplus/ERR60-CPP.+Exception+objects+must+be+nothrow+copy+constructible
 (same with this, they are probably copies of the same site)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to