mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Trim space from end of libvips error messages
This commit is contained in:
parent
0af070ed93
commit
b55e58f31e
@ -226,6 +226,13 @@ namespace sharp {
|
|||||||
return EndsWith(str, ".v") || EndsWith(str, ".V") || EndsWith(str, ".vips") || EndsWith(str, ".VIPS");
|
return EndsWith(str, ".v") || EndsWith(str, ".V") || EndsWith(str, ".vips") || EndsWith(str, ".VIPS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Trim space from end of string.
|
||||||
|
*/
|
||||||
|
std::string TrimEnd(std::string const &str) {
|
||||||
|
return str.substr(0, str.find_last_not_of(" \n\r\f") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Provide a string identifier for the given image type.
|
Provide a string identifier for the given image type.
|
||||||
*/
|
*/
|
||||||
|
@ -182,6 +182,11 @@ namespace sharp {
|
|||||||
bool IsDzZip(std::string const &str);
|
bool IsDzZip(std::string const &str);
|
||||||
bool IsV(std::string const &str);
|
bool IsV(std::string const &str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Trim space from end of string.
|
||||||
|
*/
|
||||||
|
std::string TrimEnd(std::string const &str);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Provide a string identifier for the given image type.
|
Provide a string identifier for the given image type.
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +247,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|||||||
}
|
}
|
||||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
||||||
} else {
|
} else {
|
||||||
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, baton->err).Value() });
|
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
||||||
}
|
}
|
||||||
|
|
||||||
delete baton->input;
|
delete baton->input;
|
||||||
|
@ -1234,7 +1234,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, baton->err).Value() });
|
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete baton
|
// Delete baton
|
||||||
|
@ -143,7 +143,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|||||||
info.Set("dominant", dominant);
|
info.Set("dominant", dominant);
|
||||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
||||||
} else {
|
} else {
|
||||||
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, baton->err).Value() });
|
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
||||||
}
|
}
|
||||||
|
|
||||||
delete baton->input;
|
delete baton->input;
|
||||||
|
@ -293,7 +293,7 @@ describe('Partial image extraction', function () {
|
|||||||
.extract({ left: 3000, top: 10, width: 10, height: 10 })
|
.extract({ left: 3000, top: 10, width: 10, height: 10 })
|
||||||
.toBuffer(function (err) {
|
.toBuffer(function (err) {
|
||||||
assert(err instanceof Error);
|
assert(err instanceof Error);
|
||||||
assert.strictEqual(err.message, 'extract_area: bad extract area\n');
|
assert.strictEqual(err.message, 'extract_area: bad extract area');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user