All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.launchkey.sdk.service.error.LaunchKeyException Maven / Gradle / Ivy

Go to download

SDK for interacting with the LaunchKey distributed authentication and authorization platform

There is a newer version: 4.0.0
Show newest version
/**
 * Copyright 2015 LaunchKey, Inc.  All rights reserved.
 * 

* Licensed under the MIT License. * You may not use this file except in compliance with the License. * A copy of the License is located in the "LICENSE.txt" file accompanying * this file. This file is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.launchkey.sdk.service.error; /** * Abstract exception class from which all errors in the SDK are derived */ public class LaunchKeyException extends Exception { /** * Code associated with an exception */ private final int code; /** * Get the proper exception for the provided LaunchKey message code and message * @param code LaunchKey message code * @param message Message for the error * @return Exception that properly correlates with the code */ public static LaunchKeyException fromCode(int code, String message) { LaunchKeyException error; switch (code) { case 40421: case 40433: case 40434: case 40437: case 50441: case 50446: case 50454: case 50455: case 50456: case 50457: case 60401: case 70401: case 70402: error = new InvalidRequestException(message, code); break; case 40422: case 40423: case 40425: case 40429: case 40435: case 50442: case 50443: case 50444: case 50445: case 50447: case 50449: error = new InvalidCredentialsException(message, code); break; case 40424: error = new NoPairedDevicesException(message, code); break; case 40426: error = new NoSuchUserException(message, code); break; case 40428: case 40432: case 50448: case 50452: case 50453: error = new InvalidSignatureException(message, code); break; case 40436: error = new RateLimitExceededException(message, code); break; case 40431: case 50451: case 70404: error = new ExpiredAuthRequestException(message, code); break; default: error = new LaunchKeyException(message, code); } return error; } public LaunchKeyException() { code = 0; } /** * @param message Message describing exception * @param code Code associated with exception */ public LaunchKeyException(String message, int code) { super(message); this.code = code; } /** * @param message Message describing exception * @param cause Underlying exception that caused this exception to be thrown * @param code Code associated with exception */ public LaunchKeyException(String message, Throwable cause, int code) { super(message, cause); this.code = code; } /** * Get the code associated with this exception * @return Code associated with this exception */ public int getCode() { return code; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy