Try/Catch Explanation

You should wrap all access to the SDKs in try-catch blocks, as exceptions are used to report any errors:

#include <iostream> // Print out messages to the console
#include <fstream> // Save to file
#include <P1Camera.hpp> // CameraSDK
#include <P1Image.hpp> // ImageSDK

int main(int argc, const char** argv)
{
	// All calls to the CameraSDK and ImageSDK must be wrapped in a try-catch, because all
	// exceptions are used to report errors, etc.
	P1::CameraSdk::Camera camera;
	try
	{
		//Accessing SDK
		camera = P1::CameraSdk::Camera::OpenUsbCamera();
		std::cout << "Camera connected" << std::endl;
		camera.Close();
		return 0;
	}
	catch (P1::ImageSdk::SdkException exception)
	{
		// Exception from ImageSDK
		std::cout << "Exception: " << exception.what()
			<< " Code:" << exception.mCode << std::endl;
		return 1;
	}
	catch (P1::CameraSdk::SdkException exception)
	{
		// Exception from CameraSDK
		std::cout << "Exception: " << exception.what() << " Code:"
			<< exception.mErrorCode <<
			std::endl;
		return 1;
	}
	catch (...)
	{
		// Any other exception - just in case
		std::cout << "Argh - we got an exception" << std::endl;
		return 1;
	}

}
using System;
using P1.CameraSdk;
using P1.ImageSdk;

namespace TestDocumentation3Cs
{
    class Program
    {
        static int Main(string[] args)
        {
            P1.CameraSdk.Camera camera;
            try
            {
                // Accessing the SDK
                camera = P1.CameraSdk.Camera.OpenUsbCamera();
                Console.WriteLine("Camera connected");
                camera.Close();
                return 0;
            }
            catch(P1.CameraSdk.SdkException e)
            {
                // Exception from CameraSDK
                Console.WriteLine("CameraSDK error {0} : {1}", e.ErrorCode, e.Message);
                return 1;
            }
            catch(P1.ImageSdk.SdkException e)
            {
                // Exception from ImageSDK
                Console.WriteLine("ImageSDK error {0} : {1}", e.Code, e.Message);
                return 1;
            }
            catch (Exception e)
            {
                Console.WriteLine("Any other error {0}", e.Message);
                return 1;
            }
        }
    }
}

Note

SdkException objects are thrown by the CameraSDK or ImageSDK. The second catch-block catches all other exceptions, “just in case”.