Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
 Copyright 2014 Appium contributors
 Copyright 2014 Software Freedom Conservancy
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License 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 io.appium.java_client;
import  org.openqa.selenium.WebDriverException;
import  org.openqa.selenium.remote.ErrorCodes;
Defines common error codes for the mobile JSON wire protocol.

Author(s):
jonahss@gmail.com (Jonah Stiennon)
public class ErrorCodesMobile extends ErrorCodes {
  public static final int NO_SUCH_CONTEXT = 35;
  private static Map<IntegerStringstatusToState = ImmutableMap.<IntegerString>builder()
          .put("No such context found")
          .build();

  
Returns the exception type that corresponds to the given statusCode. All unrecognized status codes will be mapped to WebDriverException.class.

Parameters:
statusCode The status code to convert.
Returns:
The exception type that corresponds to the provided status code or null if statusCode == 0.
  public Class<? extends WebDriverException> getExceptionType(int statusCode) {
    switch (statusCode) {
      case :
        return NoSuchContextException.class;
      default:
        return super.getExceptionType(statusCode);
    }
  }

  

Parameters:
message An error message returned by Appium server
Returns:
The exception type that corresponds to the provided error message or null if there are no matching mobile exceptions.
  public Class<? extends WebDriverException> getExceptionType(String message) {
    for (Map.Entry<IntegerStringentry.entrySet()) {
      if (message.contains(entry.getValue())) {
        return getExceptionType(entry.getKey());
      }
    }
    return null;
  }

  
Converts a thrown error into the corresponding status code.

Parameters:
thrown The thrown error.
Returns:
The corresponding status code for the given thrown error.
  public int toStatusCode(Throwable thrown) {
    if (thrown instanceof NoSuchContextException) {
      return ;
    } else {
      return super.toStatusCode(thrown);
    }
  }
New to GrepCode? Check out our FAQ X