java.lang.Throwable.getLocalizedMessage()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中java.lang.Throwable.getLocalizedMessage()方法的一些代码示例,展示了Throwable.getLocalizedMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Throwable.getLocalizedMessage()方法的具体详情如下:
包路径:java.lang.Throwable
类名称:Throwable
方法名:getLocalizedMessage

Throwable.getLocalizedMessage介绍

[英]Returns the detail message which was provided when this Throwable was created. Returns null if no message was provided at creation time. Subclasses may override this method to return localized text for the message. Android returns the regular detail message.
[中]返回创建此可丢弃文件时提供的详细信息。如果在创建时未提供任何消息,则返回null。子类可以重写此方法以返回消息的本地化文本。Android返回常规的详细信息。

代码示例

代码示例来源:origin: stackoverflow.com

private void makeActionOverflowMenuShown() {
  //devices with hardware menu button (e.g. Samsung Note) don't show action overflow menu
  try {
    ViewConfiguration config = ViewConfiguration.get(this);
    Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
    if (menuKeyField != null) {
      menuKeyField.setAccessible(true);
      menuKeyField.setBoolean(config, false);
    }
  } catch (Exception e) {
    Log.d(TAG, e.getLocalizedMessage());
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void stop(StopContext context) {
  if (this.stopper != null) {
    try {
      this.stopper.accept(context);
    } catch (RuntimeException | Error e) {
      LOGGER.warn(e.getLocalizedMessage(), e);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void stop(StopContext context) {
    try {
      this.destroyer.accept(this.value);
    } catch (RuntimeException | Error e) {
      LOGGER.warn(e.getLocalizedMessage(), e);
    } finally {
      this.value = null;
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void stop(StopContext context) {
    if (this.destroyer != null) {
      try {
        this.destroyer.accept(context, this.value);
      } catch (RuntimeException | Error e) {
        LOGGER.warn(e.getLocalizedMessage(), e);
      } finally {
        this.value = null;
      }
    }
  }
}

代码示例来源:origin: robovm/robovm

@Override
public String toString() {
  String msg = getLocalizedMessage();
  String name = getClass().getName();
  if (msg == null) {
    return name;
  }
  return name + ": " + msg;
}

代码示例来源:origin: nutzam/nutz

@Override
public String getLocalizedMessage() {
  StringBuilder sb = new StringBuilder();
  for (Throwable e : list)
    sb.append(e.getLocalizedMessage()).append('\n');
  return sb.toString();
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Called when a pattern cannot be compiled or some other error occurs; resets gui to valid state.
 * Thread safe.
 *
 * @param txt Error message text (friendly text appropriate for users)
 * @param e The exception that caused the problem
 */
public void doError(final String txt, final Throwable e) {
 SwingUtilities.invokeLater(() -> {
  String extraData = e.getLocalizedMessage() != null ? e.getLocalizedMessage(): (e.getClass() != null) ? e.getClass().toString(): "";
  JOptionPane.showMessageDialog(InputPanel.this, txt + '\n' + extraData, "Tregex Error", JOptionPane.ERROR_MESSAGE);
  e.printStackTrace(); // send to stderr for debugging
  useProgressBar(false);
  updateFoundStats(null, 0, 0);
 });
}

代码示例来源:origin: stackoverflow.com

private Camera openFrontFacingCameraGingerbread() {
  int cameraCount = 0;
  Camera cam = null;
  Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
  cameraCount = Camera.getNumberOfCameras();
  for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
    Camera.getCameraInfo(camIdx, cameraInfo);
    if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
      try {
        cam = Camera.open(camIdx);
      } catch (RuntimeException e) {
        Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
      }
    }
  }

  return cam;
}

代码示例来源:origin: apache/flume

@Override
public void handle(Event event, Throwable cause) throws EventDeliveryException {
 LOG.error("Event delivery failed: " + cause.getLocalizedMessage());
 LOG.debug("Exception follows.", cause);
 throw new EventDeliveryException(cause);
}

代码示例来源:origin: apache/kylin

public static ExecuteResult createError(Throwable throwable) {
  Preconditions.checkArgument(throwable != null, "throwable cannot be null");
  return new ExecuteResult(State.ERROR, throwable.getLocalizedMessage(), throwable);
}

代码示例来源:origin: pentaho/pentaho-kettle

public void onError( Throwable t ) {
 SpoonFactory.getInstance().messageBox( t.getLocalizedMessage(),
   resourceBundle.getString( "RepositoryConfigDialog.InitializationFailed" ), false, Const.ERROR ); //$NON-NLS-1$
 log.error( resourceBundle.getString( "RepositoryConfigDialog.ErrorStartingXulApplication" ), t );//$NON-NLS-1$
}

代码示例来源:origin: wildfly/wildfly

static OperationFailedException createOperationFailure(final Throwable cause) {
  final String msg = cause.getLocalizedMessage();
  // OperationFailedException's don't log the cause, for debug purposes logging the failure could be useful
  BatchLogger.LOGGER.debugf(cause, "Failed to process batch operation: %s", msg);
  return new OperationFailedException(msg, cause);
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void run() {
    try {
      this.listener.membershipChanged(this.oldMembership, this.membership, this.merged);
    } catch (Throwable e) {
      ClusteringLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e);
    }
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void onError( XulComponent sender, Throwable t ) {
  log.logDetailed( BaseMessages.getString( PKG, "RepositoryLogin.UnableToDeleteRepository", t
   .getLocalizedMessage() ) );
  new ErrorDialog( shell, BaseMessages.getString( PKG, "Dialog.Error" ), BaseMessages.getString(
   PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage() ), t );
 }
} );

代码示例来源:origin: twosigma/beakerx

@Override
 public TryResult call() throws Exception {
  TryResult r;
  try {
   r = javaEvaluator.executeTask(new JavaCodeRunner(javaEvaluator, j.outputObject, j), j.getExecutionOptions());
  } catch (Throwable e) {
   e.printStackTrace();
   r = TryResult.createError(e.getLocalizedMessage());
  }
  return r;
 }
}

代码示例来源:origin: twosigma/beakerx

@Override
public TryResult call() {
 TryResult r;
 try {
  j.outputObject.started();
  r = clojureEvaluator.executeTask(new ClojureCodeRunner(clojureEvaluator, j.codeToBeExecuted, j.outputObject), j.getExecutionOptions());
 } catch (Throwable e) {
  logger.error(e.getMessage());
  r = TryResult.createError(e.getLocalizedMessage());
 }
 return r;
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void accept(Collection<T> services, Throwable exception) {
    if (services != null) {
      try (Batch batch = CacheServiceProviderRegistry.this.batcher.createBatch()) {
        for (T service : services) {
          CacheServiceProviderRegistry.this.register(joinedMember, service);
        }
      }
    } else if (exception != null) {
      ClusteringServerLogger.ROOT_LOGGER.warn(exception.getLocalizedMessage(), exception);
    }
  }
};

代码示例来源:origin: pentaho/pentaho-kettle

public void onError( XulComponent sender, Throwable t ) {
  if ( mainController == null || !mainController.handleLostRepository( t ) ) {
   messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );//$NON-NLS-1$
   messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );//$NON-NLS-1$
   messageBox
     .setMessage( BaseMessages.getString( PKG, "RemoveRole.UnableToRemoveRole", t.getLocalizedMessage() ) );//$NON-NLS-1$
   messageBox.open();
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

public void onError( XulComponent sender, Throwable t ) {
  if ( mainController == null || !mainController.handleLostRepository( t ) ) {
   messageBox.setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );
   messageBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );
   messageBox.setMessage( BaseMessages.getString( PKG, "RemoveUser.UnableToRemoveUser", t
    .getLocalizedMessage() ) );
   messageBox.open();
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

private void onLoginError( Throwable t ) {
 if ( t instanceof KettleAuthException ) {
  ShowMessageDialog dialog =
   new ShowMessageDialog( loginDialog.getShell(), SWT.OK | SWT.ICON_ERROR, BaseMessages.getString(
    PKG, "Spoon.Dialog.LoginFailed.Title" ), t.getLocalizedMessage() );
  dialog.open();
 } else {
  new ErrorDialog(
   loginDialog.getShell(), BaseMessages.getString( PKG, "Spoon.Dialog.LoginFailed.Title" ), BaseMessages
   .getString( PKG, "Spoon.Dialog.LoginFailed.Message", t ), t );
 }
}

相关文章