LightJason - AgentSpeak(L++)
CRuntimeException.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.error;
25 
28 
29 import javax.annotation.Nonnull;
30 import java.text.MessageFormat;
31 import java.util.logging.Logger;
32 
33 
37 public final class CRuntimeException extends RuntimeException implements IContextException
38 {
42  private static final Logger LOGGER = CCommon.logger( CIllegalStateException.class );
46  private static final transient long serialVersionUID = -1053856178724776159L;
50  private final IContext m_context;
51 
52 
53 
59  public CRuntimeException( final IContext p_context )
60  {
61  super();
62  m_context = p_context;
63  LOGGER.warning( MessageFormat.format( "exception is thrown: {0}", m_context ) );
64  }
65 
72  public CRuntimeException( @Nonnull final String p_message, @Nonnull final IContext p_context )
73  {
74  super( p_message );
75  m_context = p_context;
76  LOGGER.warning( MessageFormat.format( "{0}: {1}", p_message, m_context ) );
77  }
78 
86  public CRuntimeException( @Nonnull final String p_message, @Nonnull final Throwable p_cause, @Nonnull final IContext p_context )
87  {
88  super( p_message, p_cause );
89  m_context = p_context;
90  LOGGER.warning( MessageFormat.format( "{0}: {1}", p_message, m_context ) );
91  }
92 
99  public CRuntimeException( @Nonnull final Throwable p_cause, @Nonnull final IContext p_context )
100  {
101  super( p_cause );
102  m_context = p_context;
103  LOGGER.warning( MessageFormat.format( "{0}: {1}", p_cause.getMessage(), m_context ) );
104  }
105 
115  protected CRuntimeException( final String p_message, final Throwable p_cause, final boolean p_enablesuppression,
116  final boolean p_writablestacktrace, final IContext p_context
117  )
118  {
119  super( p_message, p_cause, p_enablesuppression, p_writablestacktrace );
120  m_context = p_context;
121  LOGGER.warning( MessageFormat.format( "{0}: {1}", p_message, m_context ) );
122  }
123 
124  @Nonnull
125  @Override
126  public final IContext context()
127  {
128  return m_context;
129  }
130 
131 }
CRuntimeException( @Nonnull final Throwable p_cause, @Nonnull final IContext p_context)
ctor
execution context with local data
Definition: IContext.java:42
CRuntimeException(final String p_message, final Throwable p_cause, final boolean p_enablesuppression, final boolean p_writablestacktrace, final IContext p_context)
ctor
static Logger logger(final Class<?> p_class)
returns a logger instance
static final transient long serialVersionUID
serial id
final IContext context()
returns the execution context
CRuntimeException( @Nonnull final String p_message, @Nonnull final IContext p_context)
ctor
CRuntimeException( @Nonnull final String p_message, @Nonnull final Throwable p_cause, @Nonnull final IContext p_context)
ctor