• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 package software.amazon.awssdk.crt.mqtt;
6 
7 import software.amazon.awssdk.crt.CRT;
8 
9 /**
10  * This exception will be thrown by any exceptional cases encountered within the
11  * JNI bindings to the AWS Common Runtime
12  */
13 public class MqttException extends RuntimeException {
14     private int errorCode;
15 
16     /**
17      * @param msg mqtt exception message
18      */
MqttException(String msg)19     public MqttException(String msg) {
20         super(msg);
21         this.errorCode = -1;
22     }
23 
24     /**
25      * @param errorCode native CRT error code indicating the reason for the exception
26      */
MqttException(int errorCode)27     public MqttException(int errorCode) {
28         super(CRT.awsErrorString(errorCode));
29         this.errorCode = errorCode;
30     }
31 
32     /**
33      * Returns the error code captured when the exception occurred. This can be fed to {@link CRT.awsErrorString} to
34      * get a user-friendly error string
35      * @return The error code associated with this exception
36      */
getErrorCode()37     int getErrorCode() {
38         return errorCode;
39     }
40 };
41