lib/error and lib/file: reassign code 9 to FILE_NOT_OPEN
These are not exceptions so we don’t need multiple variants of generic error in case someone wants to catch it somewhere up the call stack. It’s okay to use UNKNOWN for generic errors where we don’t know exactly what happened.Soda
parent
ec44ac9531
commit
8bb633f118
|
@ -91,8 +91,7 @@ namespace ErrorCodes {
|
|||
|
||||
const uint8_t INVALID_TYPE = 8;
|
||||
|
||||
//file errors
|
||||
const uint8_t FILE_READ_FAILED = 9;
|
||||
const uint8_t FILE_NOT_OPEN = 9;
|
||||
const uint8_t FILE_NOT_FOUND = 10;
|
||||
|
||||
const uint8_t UNIMPLEMENTED = 254;
|
||||
|
|
|
@ -76,7 +76,7 @@ ErrorOr<uint8_t> File::readByte(){
|
|||
failure = true;
|
||||
}
|
||||
delete nextPointer;
|
||||
return failure? ErrorOr<uint8_t>(true, ErrorCodes::FILE_READ_FAILED) : ErrorOr<uint8_t>(nextByte);
|
||||
return failure? ErrorOr<uint8_t>(true, ErrorCodes::UNKNOWN) : ErrorOr<uint8_t>(nextByte);
|
||||
}
|
||||
|
||||
ErrorOr<std::vector<uint8_t>> File::read(uint64_t bytes){
|
||||
|
@ -97,7 +97,7 @@ ErrorOr<std::vector<uint8_t>> File::read(uint64_t bytes){
|
|||
failure = true;
|
||||
}
|
||||
delete[] buffer;
|
||||
return failure? ErrorOr<std::vector<uint8_t>>(true, ErrorCodes::FILE_READ_FAILED) : ErrorOr<std::vector<uint8_t>>(data);
|
||||
return failure? ErrorOr<std::vector<uint8_t>>(true, ErrorCodes::UNKNOWN) : ErrorOr<std::vector<uint8_t>>(data);
|
||||
}
|
||||
|
||||
ErrorOr<tiny_utf8::string> File::readString(uint64_t bytes){
|
||||
|
|
Loading…
Reference in New Issue