mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-08 23:04:24 +00:00
rename error and specify it in function
This commit is contained in:
parent
eeb6536c85
commit
36fa5fabc6
1 changed files with 4 additions and 4 deletions
|
|
@ -867,7 +867,7 @@ pub const TokenStream = struct {
|
||||||
parser: StreamingParser,
|
parser: StreamingParser,
|
||||||
token: ?Token,
|
token: ?Token,
|
||||||
|
|
||||||
pub const Error = StreamingParser.Error || error.Incomplete;
|
pub const Error = StreamingParser.Error || error{UnexpectedEndOfJson};
|
||||||
|
|
||||||
pub fn init(slice: []const u8) TokenStream {
|
pub fn init(slice: []const u8) TokenStream {
|
||||||
return TokenStream{
|
return TokenStream{
|
||||||
|
|
@ -878,7 +878,7 @@ pub const TokenStream = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next(self: *TokenStream) !?Token {
|
pub fn next(self: *TokenStream) Error!?Token {
|
||||||
if (self.token) |token| {
|
if (self.token) |token| {
|
||||||
const copy = token;
|
const copy = token;
|
||||||
self.token = null;
|
self.token = null;
|
||||||
|
|
@ -901,7 +901,7 @@ pub const TokenStream = struct {
|
||||||
if(self.parser.complete){
|
if(self.parser.complete){
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return error.Incomplete;
|
return error.UnexpectedEndOfJson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1456,5 +1456,5 @@ test "write json then parse it" {
|
||||||
test "parsing empty string gives appropriate error" {
|
test "parsing empty string gives appropriate error" {
|
||||||
var p = Parser.init(debug.global_allocator, false);
|
var p = Parser.init(debug.global_allocator, false);
|
||||||
defer p.deinit();
|
defer p.deinit();
|
||||||
testing.expectError(error.Incomplete, p.parse(""));
|
testing.expectError(error.UnexpectedEndOfJson, p.parse(""));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue