Skip to content

Try to use Error refactor LOG(FATAL)/CHECK - #1067

Closed
reyoung wants to merge 1 commit into
PaddlePaddle:developfrom
reyoung:feature/disable_log_fatal
Closed

reyoung wants to merge 1 commit into
PaddlePaddle:developfrom
reyoung:feature/disable_log_fatal

Conversation

@reyoung

@reyoung reyoung commented Jan 4, 2017

Copy link
Copy Markdown
Collaborator

No description provided.


TrainerConfigHelper::TrainerConfigHelper(const std::string &configFilePath)
TrainerConfigHelper::TrainerConfigHelper(
const std::string &configFilePath) throw(ErrorPtr &)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过似乎构造函数里的Error,就只能用Exception返回了。。我再想想其他办法。


#pragma once

#include <paddle/utils/Error.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照 https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes,这里应该写 `#include "paddle/utils/Error.h" 。只有system header files 才用尖括号。

Comment thread paddle/utils/Error.cpp
@@ -0,0 +1,18 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少空行。下面有些地方也缺少了空行。

Comment thread paddle/utils/Error.h
@@ -0,0 +1,28 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少空行。

Comment thread paddle/utils/Error.h
limitations under the License. */

#pragma once
#include <memory>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma 和 #include 之间缺少空行

Comment thread paddle/utils/Error.h
#pragma once
#include <memory>
#include <string>
namespace paddle {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include 和 namespace 之间缺少空行

Comment thread paddle/utils/Error.h
#include <memory>
#include <string>
namespace paddle {
typedef std::unique_ptr<std::exception> ErrorPtr;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少空行

Comment thread paddle/utils/Error.h
#include <string>
namespace paddle {
typedef std::unique_ptr<std::exception> ErrorPtr;
class Error : public std::exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少空行

Comment thread paddle/utils/Error.h
#include <string>
namespace paddle {
typedef std::unique_ptr<std::exception> ErrorPtr;
class Error : public std::exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照C++ style guide的要求,我们不应该使用exceptions,为什么要定义这个exception type?

Comment thread paddle/utils/Util.cpp
});
}

static void logAllUnhandledExceptions() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果按照style guide不用exceptions的话,貌似也就不需要log exceptions了.

@reyoung

reyoung commented Jan 12, 2017

Copy link
Copy Markdown
Collaborator Author

Closed due to I will give a better way handle errors.

@reyoung reyoung closed this Jan 12, 2017
@reyoung
reyoung deleted the feature/disable_log_fatal branch January 12, 2017 04:44
zhhsplendid pushed a commit to zhhsplendid/Paddle that referenced this pull request Sep 25, 2019
* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn

* synchronize api_en and api_cn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants