diff --git a/src/lib/file.cpp b/src/lib/file.cpp index 43f3949..08fa694 100644 --- a/src/lib/file.cpp +++ b/src/lib/file.cpp @@ -28,7 +28,7 @@ File::File(std::string path, char mode, uint64_t cursorPosition): mode(mode), pa try{ std::filesystem::path filePath = path; this->size = ErrorOr(std::filesystem::file_size(filePath)); - }catch(std::exception e){ + }catch(std::exception& e){ this->size = ErrorOr(true, ErrorCodes::FILE_NOT_FOUND); } @@ -88,7 +88,7 @@ void File::open(){ try{ std::filesystem::path filePath = this->path; this->size = ErrorOr(std::filesystem::file_size(filePath)); - }catch(std::exception e){ + }catch(std::exception& e){ this->size = ErrorOr(true, ErrorCodes::FILE_NOT_FOUND); } } @@ -114,7 +114,7 @@ ErrorOr File::readByte(){ try{ this->fileStream.read(byte, 1); delete byte; - }catch(std::exception e){ + }catch(std::exception& e){ return ErrorOr(true, ErrorCodes::FILE_READ_FAILED); } return ErrorOr((uint8_t) *byte); @@ -136,7 +136,7 @@ ErrorOr> File::read(uint64_t bytes){ data.push_back((uint8_t) buffer[i]); } delete[] buffer; - }catch(std::exception e){ + }catch(std::exception& e){ return ErrorOr>(true, ErrorCodes::FILE_READ_FAILED); } return ErrorOr>(data);