• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.base.test.transit;
6 
7 import androidx.annotation.Nullable;
8 
9 /**
10  * {@link RuntimeException}s thrown by Public Transit transitions; the message of the wrapping
11  * Exception give context to when the underlying Exception happened.
12  */
13 public class TravelException extends RuntimeException {
TravelException( @ullable TransitStation fromStation, TransitStation toStation, Throwable cause)14     public TravelException(
15             @Nullable TransitStation fromStation, TransitStation toStation, Throwable cause) {
16         super(
17                 "Did not complete transition from "
18                         + (fromStation != null ? fromStation.toString() : "<entry point>")
19                         + " to "
20                         + toStation,
21                 cause);
22     }
23 
TravelException(String message, StationFacility facility, Throwable cause)24     public TravelException(String message, StationFacility facility, Throwable cause) {
25         super(message + " " + facility, cause);
26     }
27 
newEnterFacilityException(StationFacility facility, Throwable cause)28     static TravelException newEnterFacilityException(StationFacility facility, Throwable cause) {
29         return new TravelException("Did not enter", facility, cause);
30     }
31 
newExitFacilityException(StationFacility facility, Throwable cause)32     static TravelException newExitFacilityException(StationFacility facility, Throwable cause) {
33         return new TravelException("Did not exit", facility, cause);
34     }
35 }
36