File: generic.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (25 lines) | stat: -rw-r--r-- 540 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include <alsa/asoundlib.h>

#include "common.hpp"
#include "settings.hpp"
#include "errors.hpp"

POLYBAR_NS

namespace alsa {
  DEFINE_ERROR(alsa_exception);
  DEFINE_CHILD_ERROR(mixer_error, alsa_exception);
  DEFINE_CHILD_ERROR(control_error, alsa_exception);

  template <typename T>
  void throw_exception(string&& message, int error_code) {
    const char* snd_error = snd_strerror(error_code);
    if (snd_error != nullptr)
      message += ": " + string{snd_error};
    throw T(message.c_str());
  }
}

POLYBAR_NS_END