@@ -41,6 +41,30 @@ public class Key {
4141 * @return A LicenseKey object if success and null otherwise.
4242 */
4343 public static LicenseKey Activate (String token , String RSAPubKey , ActivateModel model ) {
44+ return Activate (token , RSAPubKey , model ,null );
45+ }
46+
47+ /**
48+ * Calls the Activate method (https://app.cryptolens.io/docs/api/v3/Activate).
49+ * <p>This method allows you to retrieve the error message from the Web API.</p>
50+ * <p>
51+ * To retrieve the error message, you need to initialize an APIError object and pass it in into the
52+ * "error" parameter. For example,
53+ * </p>
54+ * <code>
55+ * APIError error = new APIError();<br>
56+ * LicenseKey license = Key.Activate(auth, RSAPubKey, new ActivateModel(3349, "ICVLD-VVSZR-ZTICT-YKGXL", Helpers.GetMachineCode()), error);<br>
57+ * System.out.println(error.Message);
58+ * </code>
59+ * @param token The access token with 'Activate' permission.
60+ * @param RSAPubKey Your RSA Public Key, which can be found at https://app.cryptolens.io/docs/api/v3/QuickStart.
61+ * @param model Method parameters.
62+ * @param error The error object whose Message field will be populated if an error has occurred. Please initialize
63+ * this parameter, i.e. define <code>APIError error = new APIError();</code> and then pass
64+ * <code>error</code> into this parameter.
65+ * @return A LicenseKey object if success and null otherwise.
66+ */
67+ public static LicenseKey Activate (String token , String RSAPubKey , ActivateModel model , APIError error ) {
4468
4569 Map <String ,String > extraParams = new HashMap <>();
4670
@@ -53,6 +77,9 @@ public static LicenseKey Activate (String token, String RSAPubKey, ActivateModel
5377
5478 if (result == null || result .result == 1 ) {
5579 if (result != null ) {
80+ if (error != null ) {
81+ error .Message = result .message ;
82+ }
5683 System .err .println ("The server returned an error: " + result .message );
5784 } else {
5885 System .err .println ("The server returned an error." );
0 commit comments