Shaka Packager SDK
status_macros.h
1 // Copyright 2018 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef PACKAGER_STATUS_MACROS_H_
8 #define PACKAGER_STATUS_MACROS_H_
9 
10 #include "packager/status.h"
11 
12 // Evaluates an expression that produces a `Status`. If the status is not
13 // ok, returns it from the current function.
14 #define RETURN_IF_ERROR(expr) \
15  do { \
16  /* Using _status below to avoid capture problems if expr is "status". */ \
17  shaka::Status _status = (expr); \
18  if (!_status.ok()) \
19  return _status; \
20  } while (0)
21 
22 // TODO(kqyang): Support build Status and update Status message through "<<".
23 
24 #endif // PACKAGER_STATUS_MACROS_H_