Add error handling, move to create methods for intrinsics.

Change-Id: I81a0d481fef8b9396c648fdf18aee716a2056612
diff --git a/cpp/Script.cpp b/cpp/Script.cpp
index 9bc55ff..29fe12d 100644
--- a/cpp/Script.cpp
+++ b/cpp/Script.cpp
@@ -28,7 +28,7 @@
 void Script::forEach(uint32_t slot, sp<const Allocation> ain, sp<const Allocation> aout,
                        const void *usr, size_t usrLen) const {
     if ((ain == NULL) && (aout == NULL)) {
-        mRS->throwError("At least one of ain or aout is required to be non-null.");
+        mRS->throwError(RS_ERROR_INVALID_PARAMETER, "At least one of ain or aout is required to be non-null.");
     }
     void *in_id = BaseObj::getObjID(ain);
     void *out_id = BaseObj::getObjID(aout);