例外を正しく使えないプログラマ多いね。 その7

このエントリーをはてなブックマークに追加
746仕様書無しさん
>>739 例えば、こういう処理にそのRuntimeExceptionの設計思想を入れるとどうなるの?

@Override
public final PaintContext getPaintContext()
{
  if( null != context ) return context;
  try
  {
    PaintContextPrototype prototype = environmentDependentContextFactory.createPaintContextPrototype();
    ・・・略・・・
    context = prototype.createPaintContext();
  }
  catch( RuntimeException exception ){ throw exception; }
  catch( XxxxxxxException exception ){ /* Xxxxxxx固有例外処理 */ }
  catch( Exception exception )
  {
    context = createSafeIndependentContext();
    ・・・略・・・
  }
  return context;
}