exception: Add exceptions when context creation fails
* Exceptions only fired in constructor when it would initialise with a NULL context causing segfaults if used any further * Adds exception.i requirement to mraa.i for node.js and python support Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include "aio.h"
|
||||
|
||||
namespace mraa {
|
||||
@@ -45,6 +46,9 @@ class Aio {
|
||||
*/
|
||||
Aio(unsigned int pin) {
|
||||
m_aio = mraa_aio_init(pin);
|
||||
if (m_aio == NULL) {
|
||||
throw std::invalid_argument("Invalid AIO pin specified - do you have an ADC?");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Aio destructor
|
||||
|
||||
Reference in New Issue
Block a user