# OrtException (onnxruntime 1.15.0 API)

Package ai.onnxruntime

## Class OrtException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - ai.onnxruntime.OrtException

All Implemented Interfaces:
  `java.io.Serializable`

    public class OrtException
    extends java.lang.Exception

An exception which contains the error message and code produced by the native onnxruntime.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `OrtException.OrtErrorCode` Maps the OrtErrorCode struct in "onnxruntime_c_api.h" with an additional entry for Java side errors.

### Constructor Summary

Constructors
`OrtException​(int code, java.lang.String message)` Used to throw an exception from native code as it handles the enum lookup in Java.
`OrtException​(OrtException.OrtErrorCode code, java.lang.String message)` Creates an OrtException using the specified error code and message.
`OrtException​(java.lang.String message)` Creates an OrtException with a default Java error code and the specified message.

### Method Summary

All Methods Instance Methods Concrete Methods
`OrtException.OrtErrorCode` `getCode()` Return the error code.

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### OrtException

    public OrtException​(java.lang.String message)

Creates an OrtException with a default Java error code and the specified message.

Parameters:
  `message` - The message to use.

#### OrtException

    public OrtException​(int code,
                        java.lang.String message)

Used to throw an exception from native code as it handles the enum lookup in Java.

Parameters:
  `code` - The error code.
  `message` - The message.

#### OrtException

    public OrtException​(OrtException.OrtErrorCode code,
                        java.lang.String message)

Creates an OrtException using the specified error code and message.

Parameters:
  `code` - The error code from the native runtime.
  `message` - The error message.

### Method Detail

#### getCode

    public OrtException.OrtErrorCode getCode()

Return the error code.

Returns:
  The error code.