You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LockFailedException.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2011, GitHub Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.errors;
  11. import java.io.File;
  12. import java.io.IOException;
  13. import java.text.MessageFormat;
  14. import org.eclipse.jgit.internal.JGitText;
  15. /**
  16. * An exception occurring when a file cannot be locked
  17. */
  18. public class LockFailedException extends IOException {
  19. private static final long serialVersionUID = 1L;
  20. private File file;
  21. /**
  22. * Constructor for LockFailedException
  23. *
  24. * @param file
  25. * file that could not be locked
  26. * @param message
  27. * exception message
  28. * @param cause
  29. * cause, for later retrieval by
  30. * {@link java.lang.Throwable#getCause()}
  31. * @since 4.1
  32. */
  33. public LockFailedException(File file, String message, Throwable cause) {
  34. super(message, cause);
  35. this.file = file;
  36. }
  37. /**
  38. * Construct a CannotLockException for the given file and message
  39. *
  40. * @param file
  41. * file that could not be locked
  42. * @param message
  43. * exception message
  44. */
  45. public LockFailedException(File file, String message) {
  46. super(message);
  47. this.file = file;
  48. }
  49. /**
  50. * Construct a CannotLockException for the given file
  51. *
  52. * @param file
  53. * file that could not be locked
  54. */
  55. public LockFailedException(File file) {
  56. this(file, MessageFormat.format(JGitText.get().cannotLock, file));
  57. }
  58. /**
  59. * Get the file that could not be locked
  60. *
  61. * @return file
  62. */
  63. public File getFile() {
  64. return file;
  65. }
  66. }