This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Get() | |
| @UseFilters(new HttpExceptionFilter()) | |
| getFuelForTokenHolders(){ | |
| throw new CustomFuelStationException('Fuel token is not valid', HttpStatus.UNAUTHORIZED) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { ExceptionFilter, Catch, ArgumentsHost, HttpException } from '@nestjs/common'; | |
| import { Request, Response } from 'express'; | |
| @Catch(HttpException) | |
| export class HttpExceptionFilter implements ExceptionFilter { | |
| catch(exception: HttpException, host: ArgumentsHost) { | |
| const ctx = host.switchToHttp(); | |
| const response = ctx.getResponse<Response>(); | |
| const request = ctx.getRequest<Request>(); | |
| const status = exception.getStatus(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Get('custom') | |
| getFuelFromAvailableStations(){ | |
| throw new CustomFuelStationException('Fuel issue only for essential service', HttpStatus.FORBIDDEN) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export class CustomFuelStationException extends HttpException{ | |
| constructor(message: string, statusCode: number) { | |
| super(message, statusCode); | |
| } | |
| } | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Get() | |
| findAllAvailableFuelStations(){ | |
| throw new HttpException('No available fuel stations', HttpStatus.NOT_FOUND); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "statusCode": 500, | |
| "message": "Internal server error" | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export interface Movie { | |
| id: string; | |
| name: string; | |
| rating: number; | |
| year: number; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { Controller, Get, HttpCode, HttpException, HttpStatus, Param } from '@nestjs/common'; | |
| import { STATUS_CODES } from 'http'; | |
| import { MoviesService } from './movies.service'; | |
| @Controller('movies') | |
| export class MoviesController { | |
| constructor(private moviesService: MoviesService) { } | |
| @Get() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { Injectable } from '@nestjs/common'; | |
| import { movies } from '../mock/movies'; | |
| import { Movie } from '../types/interfaces/movie'; | |
| @Injectable() | |
| export class MoviesService { | |
| private moviesList: Movie[]; | |
| constructor() { | |
| this.moviesList = movies; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.example.myapplication; | |
| import androidx.annotation.NonNull; | |
| import androidx.appcompat.app.AppCompatActivity; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.database.Cursor; | |
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapFactory; |