private ErrorInformation makeErrorInformation ( final Exception e ) { return new ErrorInformation ( null, e.getMessage (), ExceptionHelper.formatted ( e ) ); } }
protected static void inlineEncodeErrorInformation ( final BinaryContext context, final IoBuffer data, final org.eclipse.scada.core.data.ErrorInformation value ) throws Exception { // number of fields data.put ( (byte)3 ); // encode attributes context.encodeLong ( data, (byte)1, value.getCode () ); context.encodeString ( data, (byte)2, value.getMessage () ); context.encodeString ( data, (byte)3, value.getDiagnosticInformation () ); }
@Override public void complete ( final Future<ResponseMessage> future ) { try { final ResponseMessage result = future.get (); if ( responseClazz.isAssignableFrom ( result.getClass () ) ) { asyncSetResult ( handleResponse ( responseClazz.cast ( result ) ) ); } else if ( result instanceof ErrorResponse ) { asyncSetError ( new OperationException ( ( (ErrorResponse)result ).getErrorInformation ().getMessage () ) ); } else { asyncSetError ( new OperationException ( String.format ( "Wrong reply in message. Expected: %s, Received: %s", responseClazz.getClass (), result.getClass () ) ) ); } } catch ( final Exception e ) { asyncSetError ( e ); } } } );
@Override public void complete ( final Future<ResponseMessage> future ) { try { final ResponseMessage result = future.get (); if ( responseClazz.isAssignableFrom ( result.getClass () ) ) { asyncSetResult ( handleResponse ( responseClazz.cast ( result ) ) ); } else if ( result instanceof ErrorResponse ) { asyncSetError ( new OperationException ( ( (ErrorResponse)result ).getErrorInformation ().getMessage () ) ); } else { asyncSetError ( new OperationException ( String.format ( "Wrong reply in message. Expected: %s, Received: %s", responseClazz.getClass (), result.getClass () ) ) ); } } catch ( final Exception e ) { asyncSetError ( e ); } } } );
private ErrorInformation makeErrorInformation ( final Exception e ) { return new ErrorInformation ( null, e.getMessage (), ExceptionHelper.formatted ( e ) ); } }
private static WriteAttributeResult convertResult ( final ErrorInformation errorInformation ) { if ( errorInformation == null ) { return WriteAttributeResult.OK; } else { return new WriteAttributeResult ( new OperationException ( errorInformation.getMessage () ).fillInStackTrace () ); } }
protected static void inlineEncodeErrorInformation ( final BinaryContext context, final IoBuffer data, final org.eclipse.scada.core.data.ErrorInformation value ) throws Exception { // number of fields data.put ( (byte)3 ); // encode attributes context.encodeLong ( data, (byte)1, value.getCode () ); context.encodeString ( data, (byte)2, value.getMessage () ); context.encodeString ( data, (byte)3, value.getDiagnosticInformation () ); }
public synchronized void sendQueryState ( final QueryImpl queryImpl, final QueryState state, final Throwable error ) { final QueryImpl query = this.queries.get ( queryImpl.getQueryId () ); if ( query == null ) { return; } sendMessage ( new UpdateQueryState ( query.getQueryId (), state, new ErrorInformation ( null, error == null ? null : error.getMessage (), ExceptionHelper.formatted ( error ) ) ) ); }
private void parseCallbackResponse ( final RespondCallbacks response, final Callback[] callbacks ) { final ErrorInformation error = response.getErrorInformation (); if ( error == null && response.getCallbacks ().size () == callbacks.length ) { int i = 0; for ( final CallbackResponse cr : response.getCallbacks () ) { if ( cr.isCanceled () ) { callbacks[i].cancel (); } else { callbacks[i].parseResponseAttributes ( cr.getAttributes () ); } i++; } } else if ( error != null ) { // FIXME: should provide a real exception from error information throw new RuntimeException ( error.getMessage () ); } else { throw new RuntimeException ( "Unknown error" ); } }
private void handleSubscribeItem ( final SubscribeItem message ) { try { this.service.subscribeItem ( this.session, message.getItemId () ); } catch ( final Exception e ) { logger.warn ( "Failed to subscribe", e ); sendMessage ( new ItemStateUpdate ( message.getItemId (), SubscriptionState.DISCONNECTED, new ErrorInformation ( 0x01L, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
@Override public void complete ( final Future<ResponseMessage> future ) { try { final ResponseMessage response = future.get (); if ( response instanceof WriteValueResult ) { if ( ( (WriteValueResult)response ).getErrorInformation () == null ) { setResult ( WriteResult.OK ); } else { setError ( new OperationException ( ( (WriteValueResult)response ).getErrorInformation ().getMessage () ).fillInStackTrace () ); } } else { setError ( new IllegalStateException ( String.format ( "Wrong reply - expected: %s, got: %s", WriteValueResult.class, response ) ) ); } } catch ( final Exception e ) { setError ( e ); } } }
private void handleUnsubscibeItem ( final UnsubscibeItem message ) { try { this.service.unsubscribeItem ( this.session, message.getItemId () ); } catch ( final Exception e ) { logger.warn ( "Failed to unsubscribe", e ); sendMessage ( new ItemStateUpdate ( message.getItemId (), SubscriptionState.DISCONNECTED, new ErrorInformation ( 0x01L, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
@Override public void complete ( final Future<ResponseMessage> future ) { try { final ResponseMessage response = future.get (); if ( response instanceof WriteAttributesResult ) { if ( ( (WriteAttributesResult)response ).getErrorInformation () == null ) { setResult ( convertResults ( ( (WriteAttributesResult)response ).getAttributeResults () ) ); } else { setError ( new OperationException ( ( (WriteAttributesResult)response ).getErrorInformation ().getMessage () ).fillInStackTrace () ); } } else { setError ( new IllegalStateException ( String.format ( "Wrong reply - expected: %s, got: %s", WriteAttributesResult.class, response ) ) ); } } catch ( final Exception e ) { setError ( e ); } } }
private void handleSubscribeItem ( final SubscribeItem message ) { try { this.service.subscribeItem ( this.session, message.getItemId () ); } catch ( final Exception e ) { logger.warn ( "Failed to subscribe", e ); sendMessage ( new ItemStateUpdate ( message.getItemId (), SubscriptionState.DISCONNECTED, new ErrorInformation ( 0x01L, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
@Override public void complete ( final Future<ResponseMessage> future ) { try { final ResponseMessage response = future.get (); if ( response instanceof BrowseResult ) { if ( ( (BrowseResult)response ).getErrorInformation () == null ) { setResult ( Helper.convert ( ( (BrowseResult)response ).getBrowserData () ) ); } else { setError ( new OperationException ( ( (BrowseResult)response ).getErrorInformation ().getMessage () ).fillInStackTrace () ); } } else { setError ( new IllegalStateException ( String.format ( "Wrong reply - expected: %s, got: %s", BrowseResult.class, response ) ) ); } } catch ( final Exception e ) { setError ( e ); } } }
private void handleUnsubscibeItem ( final UnsubscibeItem message ) { try { this.service.unsubscribeItem ( this.session, message.getItemId () ); } catch ( final Exception e ) { logger.warn ( "Failed to unsubscribe", e ); sendMessage ( new ItemStateUpdate ( message.getItemId (), SubscriptionState.DISCONNECTED, new ErrorInformation ( 0x01L, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
private void sendBrowseError ( final BrowseFolder message, final Exception e, final Long code ) { sendMessage ( new BrowseResult ( new Response ( message.getRequest () ), null, new ErrorInformation ( code, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
private void sendWriteValueError ( final StartWriteValue message, final Exception e, final Long code ) { sendMessage ( new WriteValueResult ( new Response ( message.getRequest () ), new ErrorInformation ( code, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); }
private void sendBrowseError ( final BrowseFolder message, final Exception e, final Long code ) { sendMessage ( new BrowseResult ( new Response ( message.getRequest () ), null, new ErrorInformation ( code, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); } }
private void sendWriteAttributesError ( final StartWriteAttributes message, final Exception e, final Long code ) { sendMessage ( new WriteAttributesResult ( new Response ( message.getRequest () ), null, new ErrorInformation ( code, e.getMessage (), ExceptionHelper.formatted ( e ) ) ) ); }