tc-context
Version:
TwinCAT ADS Communication Library for creating an active TwinCAT Context, with automatic symbol and type mapping
206 lines (205 loc) • 8.15 kB
JavaScript
// tc-exception.ts
/**
* Module containing all the exceptions, that can be thrown by the `tc-context` library
*
*
* Licensed under MIT License.
*
* Copyright (c) 2020 Dmitrij Trifanov <d.v.trifanov@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @packageDocumentation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TcComMethodCallException = exports.TcComSymbolQueryException = exports.TcComTypeQueryException = exports.TcComDataReadException = exports.TcComDataWriteException = exports.TcComSubscribeException = exports.TcComToRawException = exports.TcComFromRawException = exports.TcComUnsubscribeException = exports.TcComChangeDetectionException = exports.TcComDisconnectException = exports.TcComConnectException = exports.TcComIsInvalidException = exports.TcComBusyException = exports.TcComException = exports.TcBindingReadOnlyException = exports.TcBindingOutOfRangeException = exports.TcBindingInvalidTypeException = exports.TcBindingIsInvalidException = exports.TcBindingException = exports.TcException = void 0;
/**
* Main Exception Class of the `tc-context` library. Every exception thrown from the `tc-context` library
* derives from this Class.
*
* Event `TcException` stores the `TcContext` from which it originated.
*/
class TcException extends Error {
constructor(context, message, arg0, arg1) {
if (arg0 instanceof Error) {
super(`${message}\nAdditional Information:\n${arg0.message}`);
this.__parent = arg0;
this.__data = arg1;
}
else if (arg0) {
super(message);
this.__data = arg0;
}
else
super(message);
this.__context = context;
}
;
/**
* Access the `TcContext`, from which this `TcException` originated
*/
get context() { return this.__context; }
;
/**
* Access any data, associated with this `TcException`
*/
get data() { return this.__data; }
;
/**
* Access any parent error, that was raised alongside this `TcException`
*/
get parent() { return this.__parent; }
;
}
exports.TcException = TcException;
/**
* Exception Class, for every Error produced by the `TcBinding` Object through the `TcSymbol` Object
*
* Will also store the `TcBinding`, that threw the exception originally
*/
class TcBindingException extends TcException {
constructor(context, sender, message, arg0, arg1) {
super(context, message, arg0, arg1);
this.__sender = sender;
}
/**
* Access the `TcBinding`, from which this `TcException` originated
*/
get sender() { return this.__sender; }
}
exports.TcBindingException = TcBindingException;
/**
* Exception raised when an operation was called on an invalidated `TcBinding`
*/
class TcBindingIsInvalidException extends TcBindingException {
}
exports.TcBindingIsInvalidException = TcBindingIsInvalidException;
;
/**
* Exception raised when an invalid type was passed to the `TcBinding`
*/
class TcBindingInvalidTypeException extends TcBindingException {
}
exports.TcBindingInvalidTypeException = TcBindingInvalidTypeException;
/**
* Exception raised when a value that is out of allowed range was passed to the `TcBinding`
*/
class TcBindingOutOfRangeException extends TcBindingException {
}
exports.TcBindingOutOfRangeException = TcBindingOutOfRangeException;
/**
* Exception raised when a write operation was called on a ReadOnly `TcBinding`
*/
class TcBindingReadOnlyException extends TcBindingException {
}
exports.TcBindingReadOnlyException = TcBindingReadOnlyException;
/**
* Exception Class, for every Error produced by the `TcCom` Object
*
* Will also store the `TcCom`, that threw the exception originally
*/
class TcComException extends TcException {
constructor(context, sender, message, arg0, arg1) {
super(context, message, arg0, arg1);
this.__sender = sender;
}
/**
* Access the `TcCom`, from which this `TcException` originated
*/
get sender() { return this.__sender; }
}
exports.TcComException = TcComException;
/**
* Exception raised when an operation was called on an uninitialized `TcCom`
*/
class TcComBusyException extends TcComException {
}
exports.TcComBusyException = TcComBusyException;
/**
* Exception raised when an operation was called on an invalidated `TcCom`
*/
class TcComIsInvalidException extends TcComException {
}
exports.TcComIsInvalidException = TcComIsInvalidException;
/**
* Exception raised when an error happens during ADS Connection
*/
class TcComConnectException extends TcComException {
}
exports.TcComConnectException = TcComConnectException;
/**
* Exception raised when an error happens during ADS Disconnect
*/
class TcComDisconnectException extends TcComException {
}
exports.TcComDisconnectException = TcComDisconnectException;
/**
* Exception raised when an error happens during an attempt to monitor Code Changes
*/
class TcComChangeDetectionException extends TcComException {
}
exports.TcComChangeDetectionException = TcComChangeDetectionException;
/**
* Exception raised when an error happens during unsubscribing from a Target PLC Symbol
*/
class TcComUnsubscribeException extends TcComException {
}
exports.TcComUnsubscribeException = TcComUnsubscribeException;
/**
* Exception raised when an error happens during conversion of values to Raw Data
*/
class TcComFromRawException extends TcComException {
}
exports.TcComFromRawException = TcComFromRawException;
/**
* Exception raised when an error happens during conversion of Raw Data to values
*/
class TcComToRawException extends TcComException {
}
exports.TcComToRawException = TcComToRawException;
/**
* Exception raised when an error happens during subscription to a Target PLC Symbol
*/
class TcComSubscribeException extends TcComException {
}
exports.TcComSubscribeException = TcComSubscribeException;
/**
* Exception raised when an error happens during ADS Write operation
*/
class TcComDataWriteException extends TcComException {
}
exports.TcComDataWriteException = TcComDataWriteException;
/**
* Exception raised when an error happens during ADS Read operation
*/
class TcComDataReadException extends TcComException {
}
exports.TcComDataReadException = TcComDataReadException;
/**
* Exception raised when an error happens during the fetch of ADS Type Data
*/
class TcComTypeQueryException extends TcComException {
}
exports.TcComTypeQueryException = TcComTypeQueryException;
/**
* Exception raised when an error happens during the fetch of ADS Symbol Data
*/
class TcComSymbolQueryException extends TcComException {
}
exports.TcComSymbolQueryException = TcComSymbolQueryException;
/**
* Exception raised when an error happens during a call to a Method of a Function Block
*/
class TcComMethodCallException extends TcComException {
}
exports.TcComMethodCallException = TcComMethodCallException;
;